Closed janflyborgw closed 1 year ago
I have the need to convert instances of json_t into their corresponding textual JS representation. For instance:
char *s = json_dumps(json_string("An example string"), JSON_COMPACT); char *s = json_dumps(json_true(), JSON_COMPACT);
char *s = json_dumps(json_string("An example string"), JSON_COMPACT);
char *s = json_dumps(json_true(), JSON_COMPACT);
should give the string "An example string" and the string true
"An example string"
true
But it seems like json_dumps can only handle objects and I guess this is by design, but is there another way to accomplish this, (apart from implementing it myself)?
Got it. Found the JSON_ENCODE_ANY flag. Sorry for the confusion.
I have the need to convert instances of json_t into their corresponding textual JS representation. For instance:
char *s = json_dumps(json_string("An example string"), JSON_COMPACT);
char *s = json_dumps(json_true(), JSON_COMPACT);
should give the string
"An example string"
and the stringtrue
But it seems like json_dumps can only handle objects and I guess this is by design, but is there another way to accomplish this, (apart from implementing it myself)?