Export - query
- Output from the query command is now optionally surrounded by [ ... ] to make this a syntactically correct JSON document. This is off by default. - Updated documents.
This commit is contained in:
@@ -97,6 +97,7 @@ std::string Config::defaults =
|
||||
"xterm.title=no # Sets xterm title for some commands\n"
|
||||
"expressions=on # Support for algebraic expressions\n"
|
||||
"patterns=on # Support for regex patterns\n"
|
||||
"json.array=off # Enclose JSON output in [ ]\n"
|
||||
"\n"
|
||||
"# Dates\n"
|
||||
"dateformat=m/d/Y # Preferred input and display date format\n"
|
||||
|
||||
@@ -75,7 +75,13 @@ int CmdQuery::execute (std::string& output)
|
||||
// Note: "limit:" feature not supported.
|
||||
// TODO Why not?
|
||||
|
||||
// Is output contained within a JSON array?
|
||||
bool json_array = context.config.getBoolean ("json.array");
|
||||
|
||||
// Compose output.
|
||||
if (json_array)
|
||||
output += "[\n";
|
||||
|
||||
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||
{
|
||||
if (task != filtered.begin ())
|
||||
@@ -84,6 +90,9 @@ int CmdQuery::execute (std::string& output)
|
||||
output += task->composeJSON (true);
|
||||
}
|
||||
|
||||
if (json_array)
|
||||
output += "\n]";
|
||||
|
||||
output += "\n";
|
||||
return rc;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user