mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-28 04:27:20 +02:00
JSON
- Tags are now a JSON array: "tags":["one","two"]
This commit is contained in:
parent
2d50d1cbf5
commit
18aa5c5b69
1 changed files with 25 additions and 0 deletions
25
src/Task.cpp
25
src/Task.cpp
|
@ -443,10 +443,13 @@ std::string Task::composeJSON () const
|
||||||
if (attributes_written)
|
if (attributes_written)
|
||||||
out << ",";
|
out << ",";
|
||||||
|
|
||||||
|
// Annotations are simply counted.
|
||||||
if (i->second.name ().substr (0, 11) == "annotation_")
|
if (i->second.name ().substr (0, 11) == "annotation_")
|
||||||
{
|
{
|
||||||
++annotation_count;
|
++annotation_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Date fields are written as ISO 8601.
|
||||||
else if (att.type (i->second.name ()) == "date")
|
else if (att.type (i->second.name ()) == "date")
|
||||||
{
|
{
|
||||||
Date d (i->second.value ());
|
Date d (i->second.value ());
|
||||||
|
@ -458,6 +461,28 @@ std::string Task::composeJSON () const
|
||||||
|
|
||||||
++attributes_written;
|
++attributes_written;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tags are converted to an array.
|
||||||
|
else if (i->second.name () == "tags")
|
||||||
|
{
|
||||||
|
std::vector <std::string> tags;
|
||||||
|
split (tags, i->second.value (), ',');
|
||||||
|
|
||||||
|
out << "\"tags\":[";
|
||||||
|
|
||||||
|
std::vector <std::string>::iterator i;
|
||||||
|
for (i = tags.begin (); i != tags.end (); ++i)
|
||||||
|
{
|
||||||
|
if (i != tags.begin ())
|
||||||
|
out << ",";
|
||||||
|
|
||||||
|
out << "\"" << *i << "\"";
|
||||||
|
}
|
||||||
|
|
||||||
|
out << "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Everything else is a quoted value.
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
out << "\""
|
out << "\""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue