Implemented a decode option to only decode numbers to reals and never integers
This commit is contained in:
parent
042d4b2a6b
commit
9e7f11a847
@ -239,6 +239,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
|
||||
#define JSON_DECODE_NO_INT 0x8
|
||||
|
||||
typedef size_t (*json_load_callback_t)(void *buffer, size_t buflen, void *data);
|
||||
|
||||
|
@ -783,7 +783,11 @@ static json_t *parse_value(lex_t *lex, size_t flags, json_error_t *error)
|
||||
}
|
||||
|
||||
case TOKEN_INTEGER: {
|
||||
json = json_integer(lex->value.integer);
|
||||
if (flags & JSON_DECODE_NO_INT) {
|
||||
json = json_real(lex->value.integer);
|
||||
} else {
|
||||
json = json_integer(lex->value.integer);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user