JSON_DECODE_ANY

Closes GH-4.
This commit is contained in:
Andrea Marchesini
2011-11-11 19:17:29 +01:00
committed by Petri Lehtinen
parent 72cd84b92a
commit 1e36667193
4 changed files with 43 additions and 3 deletions

View File

@@ -222,6 +222,7 @@ json_t *json_deep_copy(json_t *value);
#define JSON_REJECT_DUPLICATES 0x1
#define JSON_DISABLE_EOF_CHECK 0x2
#define JSON_DECODE_ANY 0x4
json_t *json_loads(const char *input, size_t flags, json_error_t *error);
json_t *json_loadb(const char *buffer, size_t buflen, size_t flags, json_error_t *error);

View File

@@ -820,9 +820,11 @@ static json_t *parse_json(lex_t *lex, size_t flags, json_error_t *error)
json_t *result;
lex_scan(lex, error);
if(lex->token != '[' && lex->token != '{') {
error_set(error, lex, "'[' or '{' expected");
return NULL;
if(!(flags & JSON_DECODE_ANY)) {
if(lex->token != '[' && lex->token != '{') {
error_set(error, lex, "'[' or '{' expected");
return NULL;
}
}
result = parse_value(lex, flags, error);