Implemented a decode option to only decode numbers to reals and never integers

This commit is contained in:
Jason Choy 2013-06-09 15:14:47 +01:00
parent 042d4b2a6b
commit 9e7f11a847
2 changed files with 6 additions and 1 deletions

View File

@ -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);

View File

@ -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;
}