src/json.c

changeset 1340
31c61b6dcaa5
parent 1338
cc153bffea28
equal deleted inserted replaced
1339:bff0a078523d 1340:31c61b6dcaa5
1150 ); 1150 );
1151 } 1151 }
1152 1152
1153 CxJsonValue *cx_json_obj_get_cxstr(const CxJsonValue *value, cxstring name) { 1153 CxJsonValue *cx_json_obj_get_cxstr(const CxJsonValue *value, cxstring name) {
1154 size_t index = json_find_objvalue(value, name); 1154 size_t index = json_find_objvalue(value, name);
1155 if (index == value->value.object.values_size) { 1155 if (index >= value->value.object.values_size) {
1156 return &cx_json_value_nothing; 1156 return &cx_json_value_nothing;
1157 } else { 1157 } else {
1158 return value->value.object.values[index].value; 1158 return value->value.object.values[index].value;
1159 } 1159 }
1160 } 1160 }
1161 1161
1162 CxJsonValue *cx_json_obj_remove_cxstr(CxJsonValue *value, cxstring name) { 1162 CxJsonValue *cx_json_obj_remove_cxstr(CxJsonValue *value, cxstring name) {
1163 size_t index = json_find_objvalue(value, name); 1163 size_t index = json_find_objvalue(value, name);
1164 if (index == value->value.object.values_size) { 1164 if (index >= value->value.object.values_size) {
1165 return NULL; 1165 return NULL;
1166 } else { 1166 } else {
1167 CxJsonObjValue kv = value->value.object.values[index]; 1167 CxJsonObjValue kv = value->value.object.values[index];
1168 cx_strfree_a(value->allocator, &kv.name); 1168 cx_strfree_a(value->allocator, &kv.name);
1169 // TODO: replace with cx_array_remove() 1169 // TODO: replace with cx_array_remove()

mercurial