HI Mynewt Team,
Wanted some assistance on how to encode and decode the following JSON
string.
{“name1":1,”name2”:"value2”,"name3":[{“name4":1,”name5":5}]}
Because of sparse documentation, I used the Test sample; however am
stuck with encoding an array of objects.
struct json_encoder *encoder, *module;
struct json_value value;
json_encode_object_start(encoder);
JSON_VALUE_INT(value, 1);
json_encode_object_entry(encoder, “name1", value);
JSON_VALUE_STRING(value, “value2”);
json_encode_object_entry(encoder, “name2", value);
json_encode_array_name(encoder, “name3”);
json_encode_array_start(encoder);
json_encode_object_start(module);
//Is this correct ?
JSON_VALUE_INT(value, 1);
json_encode_object_entry(encoder, “name4", value);
JSON_VALUE_INT(&value, 1);
json_encode_object_entry(encoder, “name5", value);
json_encode_object_finish(module);
// How to insert this object into the array ?
json_encode_array_finish(encoder);
json_encode_object_finish(encoder);
I followed the example provided at
https://mynewt.apache.org/latest/os/modules/json/json_encode_object_entry
<https://mynewt.apache.org/latest/os/modules/json/json_encode_object_entry>
And it gives me error :-
error: implicit declaration of function 'json_encode_object_start'
Thanks,
Aditya Xavier.