From 18aa5c5b6958670aa52fb5aca2f4e43bbea14bcc Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 25 Jan 2011 23:17:28 -0500 Subject: [PATCH] JSON - Tags are now a JSON array: "tags":["one","two"] --- src/Task.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/Task.cpp b/src/Task.cpp index 6456d80f2..9e34679ff 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -443,10 +443,13 @@ std::string Task::composeJSON () const if (attributes_written) out << ","; + // Annotations are simply counted. if (i->second.name ().substr (0, 11) == "annotation_") { ++annotation_count; } + + // Date fields are written as ISO 8601. else if (att.type (i->second.name ()) == "date") { Date d (i->second.value ()); @@ -458,6 +461,28 @@ std::string Task::composeJSON () const ++attributes_written; } + + // Tags are converted to an array. + else if (i->second.name () == "tags") + { + std::vector tags; + split (tags, i->second.value (), ','); + + out << "\"tags\":["; + + std::vector ::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 { out << "\""