mirror of
https://github.com/owntracks/recorder.git
synced 2026-02-13 20:49:51 +00:00
ocat JSON output now supports emitting fields which are arrays/lists
closes #542
This commit is contained in:
@@ -516,9 +516,9 @@ Some example uses we consider useful:
|
|||||||
* `ocat --last`
|
* `ocat --last`
|
||||||
print the LAST position of all users, devices. Can be combined with `--user` and `--device`.
|
print the LAST position of all users, devices. Can be combined with `--user` and `--device`.
|
||||||
* `ocat ... --format csv`
|
* `ocat ... --format csv`
|
||||||
produces CSV. Limit the fields you want extracted with `--fields lat,lon,cc` for example.
|
produces CSV. Limit the fields you want extracted with `--fields lat,lon,cc` for example. (Note: fields which are arrays or lists are not supported.)
|
||||||
* `ocat ... --format xml`
|
* `ocat ... --format xml`
|
||||||
produces XML. Limit the fields you want extracted with `--fields lat,lon,cc` for example.
|
produces XML. Limit the fields you want extracted with `--fields lat,lon,cc` for example. (Note: fields which are arrays or lists are not supported.)
|
||||||
```xml
|
```xml
|
||||||
<?xml version='1.0' encoding='UTF-8'?>
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
<?xml-stylesheet type='text/xsl' href='owntracks.xsl'?>
|
<?xml-stylesheet type='text/xsl' href='owntracks.xsl'?>
|
||||||
@@ -549,7 +549,7 @@ Some example uses we consider useful:
|
|||||||
* `ocat ... --limit 10`
|
* `ocat ... --limit 10`
|
||||||
prints data for the current month, starting now and going backwards; only 10 locations will be printed. Generally, the `--limit` option reads the storage back to front which makes no sense in some combinations.
|
prints data for the current month, starting now and going backwards; only 10 locations will be printed. Generally, the `--limit` option reads the storage back to front which makes no sense in some combinations.
|
||||||
|
|
||||||
Specifying `--fields lat,tid,lon` will request just those JSON elements from the store. (Note that doing so with output GPX or GEOJSON could render those formats useless if, say, `lat` is missing in the list of fields.)
|
Specifying `--fields lat,tid,lon` will request just those JSON elements from the store. (Note that doing so with output GPX or GEOJSON could render those formats useless if, say, `lat` is missing in the list of fields. Also note, that currently fields which are arrays or lists are supported only the JSON output.)
|
||||||
|
|
||||||
The `--from` and `--to` options allow you to specify a UTC date and/or timestamp from which respectively until which data will be read. By default, the last 6 hours of data are produced. If `--from` is not specified, it therefore defaults to "now minus 6 hours". If `--to` is not specified it defaults to "now". Dates and times must be specified as strings, and the following formats are recognized:
|
The `--from` and `--to` options allow you to specify a UTC date and/or timestamp from which respectively until which data will be read. By default, the last 6 hours of data are produced. If `--from` is not specified, it therefore defaults to "now minus 6 hours". If `--to` is not specified it defaults to "now". Dates and times must be specified as strings, and the following formats are recognized:
|
||||||
|
|
||||||
|
|||||||
5
util.c
5
util.c
@@ -142,6 +142,11 @@ int json_copy_element_to_object(JsonNode *obj, char *key, JsonNode *node)
|
|||||||
json_append_member(obj, key, json_mkbool(node->bool_));
|
json_append_member(obj, key, json_mkbool(node->bool_));
|
||||||
else if (node->tag == JSON_NULL)
|
else if (node->tag == JSON_NULL)
|
||||||
json_append_member(obj, key, json_mknull());
|
json_append_member(obj, key, json_mknull());
|
||||||
|
else if (node->tag == JSON_ARRAY) {
|
||||||
|
JsonNode *new_array = json_mkarray();
|
||||||
|
json_copy_to_object(new_array, node, false);
|
||||||
|
json_append_member(obj, key, new_array);
|
||||||
|
}
|
||||||
|
|
||||||
return (TRUE);
|
return (TRUE);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user