mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Interval: Proper handling of commas in JSON
This commit is contained in:
parent
71b2320def
commit
07c9d587e9
1 changed files with 13 additions and 5 deletions
|
@ -201,13 +201,17 @@ std::string Interval::serialize () const
|
|||
std::string Interval::json () const
|
||||
{
|
||||
std::stringstream out;
|
||||
out << "{";
|
||||
out << '{';
|
||||
|
||||
if (_start.toEpoch ())
|
||||
out << "\"start\":\"" << _start.toISO () << "\"";
|
||||
|
||||
if (_end.toEpoch ())
|
||||
out << ",\"end\":\"" << _end.toISO () << "\"";
|
||||
{
|
||||
if (_start.toEpoch ())
|
||||
out << ',';
|
||||
out << "\"end\":\"" << _end.toISO () << "\"";
|
||||
}
|
||||
|
||||
if (_tags.size ())
|
||||
{
|
||||
|
@ -215,14 +219,18 @@ std::string Interval::json () const
|
|||
for (auto& tag : _tags)
|
||||
{
|
||||
if (tags[0])
|
||||
tags += ",";
|
||||
tags += ',';
|
||||
|
||||
tags += "\"" + tag + "\"";
|
||||
}
|
||||
|
||||
out << ",\"tags\":["
|
||||
if (_start.toEpoch () ||
|
||||
_end.toEpoch ())
|
||||
out << ',';
|
||||
|
||||
out << "\"tags\":["
|
||||
<< tags
|
||||
<< "]";
|
||||
<< ']';
|
||||
}
|
||||
|
||||
out << "}";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue