diff --git a/lib/misc/lejp.c b/lib/misc/lejp.c index b898c6f93..c0c2bf2c6 100644 --- a/lib/misc/lejp.c +++ b/lib/misc/lejp.c @@ -580,7 +580,8 @@ lejp_parse(struct lejp_ctx *ctx, const unsigned char *json, int len) } ctx->buf[ctx->npos] = '\0'; - if (ctx->f & LEJP_SEEN_POINT) { + if (ctx->f & (LEJP_SEEN_POINT | LEJP_SEEN_EXP)) { + /* 0.001 or 1E-3 are both floats, take 1E3 as float too */ if (ctx->pst[ctx->pst_sp].callback(ctx, LEJPCB_VAL_NUM_FLOAT)) goto reject_callback; diff --git a/minimal-examples/api-tests/api-test-lejp/main.c b/minimal-examples/api-tests/api-test-lejp/main.c index 352181bbd..8c5600915 100644 --- a/minimal-examples/api-tests/api-test-lejp/main.c +++ b/minimal-examples/api-tests/api-test-lejp/main.c @@ -127,6 +127,10 @@ static const char * const json_tests[] = { "{" /* SHOULD_FAIL: test 10, missing open */ "\"a\":123,\"b\":}" + "}", + + "{" /* test 13: float vs int */ + "\"a\": 1, \"b\": 1.0, \"c\": 1e-3, \"d\": 1e3" "}" };