tests/test_json.c

changeset 1582
32b82c424252
parent 1573
cd2e974410ad
child 1586
7f1cadc3ebc1
equal deleted inserted replaced
1581:814049fb62ee 1582:32b82c424252
1252 static CxJsonValue *test_json_write_create_test_object(const CxAllocator *allocator) { 1252 static CxJsonValue *test_json_write_create_test_object(const CxAllocator *allocator) {
1253 CxJsonValue *obj = cxJsonCreateObj(allocator); 1253 CxJsonValue *obj = cxJsonCreateObj(allocator);
1254 cxJsonObjPutLiteral(obj, "bool", CX_JSON_FALSE); 1254 cxJsonObjPutLiteral(obj, "bool", CX_JSON_FALSE);
1255 cxJsonObjPutNumber(obj, "int", 47); // purposely use PutNumber to put an int 1255 cxJsonObjPutNumber(obj, "int", 47); // purposely use PutNumber to put an int
1256 CxJsonValue *strings = cxJsonObjPutArr(obj, "strings"); 1256 CxJsonValue *strings = cxJsonObjPutArr(obj, "strings");
1257 cxJsonArrAddCxStrings(strings, (cxstring[]) {CX_STR("hello"), CX_STR("world")}, 2); 1257 cxJsonArrAddCxStrings(strings, (cxstring[]) {cx_str("hello"), cx_str("world")}, 2);
1258 CxJsonValue *nested = cxJsonObjPutObj(obj, "nested"); 1258 CxJsonValue *nested = cxJsonObjPutObj(obj, "nested");
1259 CxJsonValue *objects = cxJsonObjPutArr(nested, "objects"); 1259 CxJsonValue *objects = cxJsonObjPutArr(nested, "objects");
1260 CxJsonValue *obj_in_arr[2] = {cxJsonCreateObj(allocator), cxJsonCreateObj(allocator)}; 1260 CxJsonValue *obj_in_arr[2] = {cxJsonCreateObj(allocator), cxJsonCreateObj(allocator)};
1261 cxJsonObjPutInteger(obj_in_arr[0], "name1", 1); 1261 cxJsonObjPutInteger(obj_in_arr[0], "name1", 1);
1262 cxJsonObjPutInteger(obj_in_arr[0], "name2", 3); 1262 cxJsonObjPutInteger(obj_in_arr[0], "name2", 3);

mercurial