These are chat archives for cortoproject/corto

28th
Aug 2016
Sander Mertens
@SanderMertens
Aug 28 2016 03:22
@KrishnaPG it is very easy to use JSON with Corto
If you have an existing object you can use this function: char* str = corto_contentof(NULL, "text/json", obj)
You can also set the value in JSON, with the corto_fromcontent function:
corto_fromcontent(o, "text/json", "{\"x\":10,\"y\":20}");
You can also use the corto_select function to request data from the object store, and specify JSON as the contentType. For example:
Sander Mertens
@SanderMertens
Aug 28 2016 03:28
To select all objects from the store, and get the values in JSON:
corto_resultIter iter;
corto_select(NULL, "//*").contentType("text/json").iter(&iter);
corto_resultIterForeach(iter, r) {
    printf("id = %s, type = %s, value = %s\n",
        r.id, r.type, corto_resultGetText(&r));
}
Note that JSON is just one possible encoding. The corto framework makes it very easy to create your own encodings (for example, the cortoproject/influxdb repository has an encoding for the influxdb line format).
For more information on the corto_select function: https://corto.io/doc/api.html#Queries_corto_select