goto truncated;
if (!strchr(top->acc, c))
goto invalid_character;
- d = skip(++d);
+ d = skip(d + 1);
switch(c) {
case 's':
nullable = 0;
if (strs[nstr].str)
notnull = 1;
if (*d == '?') {
- d = skip(++d);
+ d = skip(d + 1);
nullable = 1;
}
switch(*d) {
- case '%': strs[nstr].sz = va_arg(args, size_t); d = skip(++d); break;
- case '#': strs[nstr].sz = (size_t)va_arg(args, int); d = skip(++d); break;
+ case '%': strs[nstr].sz = va_arg(args, size_t); d = skip(d + 1); break;
+ case '#': strs[nstr].sz = (size_t)va_arg(args, int); d = skip(d + 1); break;
default: strs[nstr].sz = strs[nstr].str ? strlen(strs[nstr].str) : 0; break;
}
sz += strs[nstr++].sz;
if (*d == '?') {
- d = skip(++d);
+ d = skip(d + 1);
nullable = 1;
}
if (*d != '+')
break;
if (nstr >= STRCOUNT)
goto too_long;
- d = skip(++d);
+ d = skip(d + 1);
}
if (*d == '*')
nullable = 1;
case 'O':
obj = va_arg(args, struct json_object*);
if (*d == '?')
- d = skip(++d);
+ d = skip(d + 1);
else if (*d != '*' && !obj)
goto null_object;
if (c == 'O')
goto out_of_memory;
}
if (*d == '?')
- d = skip(++d);
+ d = skip(d + 1);
else if (*d != '*' && !obj) {
obj = json_object_new_string_len(d, 0);
if (!obj)
if (obj || *d != '*')
json_object_array_add(top->cont, obj);
if (*d == '*')
- d = skip(++d);
+ d = skip(d + 1);
break;
case '}':
if (!obj)
if (obj || *d != '*')
json_object_object_add(top->cont, json_object_get_string(top->key), obj);
if (*d == '*')
- d = skip(++d);
+ d = skip(d + 1);
json_object_put(top->key);
top->key = NULL;
top->acc = pack_accept_key;
goto truncated;
if (!strchr(acc, c))
goto invalid_character;
- d = skip(++d);
+ d = skip(d + 1);
switch(c) {
case 's':
if (xacc[0] == '}') {
optionnal = 0;
else {
optionnal = 1;
- d = skip(++d);
+ d = skip(d + 1);
}
if (ignore)
ignore++;
*ps = json_object_get_string(obj);
}
if (*d == '%') {
- d = skip(++d);
+ d = skip(d + 1);
if (store) {
pz = va_arg(args, size_t *);
if (!ignore && pz)
va_list args;
va_start(args, desc);
- rc = vunpack(object, desc, args, 0);
+ rc = wrap_json_vcheck(object, desc, args);
va_end(args);
return rc;
}
va_list args;
va_start(args, desc);
- rc = vunpack(object, desc, args, 0);
+ rc = wrap_json_vmatch(object, desc, args);
va_end(args);
- return !rc;
+ return rc;
}
int wrap_json_vunpack(struct json_object *object, const char *desc, va_list args)
#if defined(WRAP_JSON_TEST)
#include <stdio.h>
+#if !defined(JSON_C_TO_STRING_NOSLASHESCAPE)
+#define JSON_C_TO_STRING_NOSLASHESCAPE 0
+#endif
+#define j2t(o) json_object_to_json_string_ext((o), JSON_C_TO_STRING_NOSLASHESCAPE)
void tclone(struct json_object *object)
{
o = wrap_json_clone(object);
if (!wrap_json_equal(object, o))
- printf("ERROR in clone or equal: %s VERSUS %s\n", json_object_to_json_string(object), json_object_to_json_string(o));
+ printf("ERROR in clone or equal: %s VERSUS %s\n", j2t(object), j2t(o));
json_object_put(o);
o = wrap_json_clone_deep(object);
if (!wrap_json_equal(object, o))
- printf("ERROR in clone_deep or equal: %s VERSUS %s\n", json_object_to_json_string(object), json_object_to_json_string(o));
+ printf("ERROR in clone_deep or equal: %s VERSUS %s\n", j2t(object), j2t(o));
json_object_put(o);
}
rc = wrap_json_vpack(&result, desc, args);
va_end(args);
if (!rc)
- printf(" SUCCESS %s\n\n", json_object_to_json_string(result));
+ printf(" SUCCESS %s\n\n", j2t(result));
else
printf(" ERROR[char %d err %d] %s\n\n", wrap_json_get_error_position(rc), wrap_json_get_error_code(rc), wrap_json_get_error_string(rc));
tclone(result);
case 'I': printf(" I:%lld", *va_arg(args, int64_t*)); k = m&1; break;
case 'f': printf(" f:%f", *va_arg(args, double*)); k = m&1; break;
case 'F': printf(" F:%f", *va_arg(args, double*)); k = m&1; break;
- case 'o': printf(" o:%s", json_object_to_json_string(*va_arg(args, struct json_object**))); k = m&1; break;
- case 'O': o = *va_arg(args, struct json_object**); printf(" O:%s", json_object_to_json_string(o)); json_object_put(o); k = m&1; break;
+ case 'o': printf(" o:%s", j2t(*va_arg(args, struct json_object**))); k = m&1; break;
+ case 'O': o = *va_arg(args, struct json_object**); printf(" O:%s", j2t(o)); json_object_put(o); k = m&1; break;
case 'y':
case 'Y': {
uint8_t *p = *va_arg(args, uint8_t**);