From 641cfa3fefed6f4e9fd55e3024ac4d549076915b Mon Sep 17 00:00:00 2001 From: Franz Auernigg Date: Wed, 8 Sep 2021 13:30:26 +0200 Subject: [PATCH] json: fix parsing json containing only single value Fix parsing simple json containing only 1 value without a name .e.g. '"HelloWorld"' or '42' --- src/json/decode.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/json/decode.c b/src/json/decode.c index 067ecff5d..d20668225 100644 --- a/src/json/decode.c +++ b/src/json/decode.c @@ -443,10 +443,16 @@ static int _json_decode(const char **str, size_t *len, if (**str == '\"') inquot = true; - val.p = *str; val.l = 0; ws = 0; + + if (!inobj && !inarray) { + val.l = *len; + if (array_entry(idx, &val, aeh, arg)) + val.l = 0; + } + break; } }