From 8a4f45db71d4e77c869d1389b7828735bfa02fcc Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Fri, 15 Dec 2023 23:31:50 -0500 Subject: [PATCH] fix json fp precision, fix multi value json compound tags --- src/json/print.c | 4 ++-- src/json/read.c | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/json/print.c b/src/json/print.c index e8b6996..97ccce8 100644 --- a/src/json/print.c +++ b/src/json/print.c @@ -124,10 +124,10 @@ static bool json_print_data(const tag_t *tag, const stream_t *stream, int depth) ok = printi(stream, 0, "%ld", tag->data.l); break; case TAG_FLOAT: - ok = printi(stream, 0, "%f", tag->data.f); + ok = printi(stream, 0, "%.9g", tag->data.f); break; case TAG_DOUBLE: - ok = printi(stream, 0, "%lf", tag->data.d); + ok = printi(stream, 0, "%.17g", tag->data.d); break; case TAG_BYTE_ARRAY: ok = json_print_byte_array(&tag->data, stream); diff --git a/src/json/read.c b/src/json/read.c index b95bc13..1401633 100644 --- a/src/json/read.c +++ b/src/json/read.c @@ -562,6 +562,11 @@ static bool json_read_compound(tagdata_t *data, const stream_t *stream) { } if (next.type == TOK_COMMA) { + if (json_next_token(&next, stream) == false) { + free(tags); + free(name); + return false; + } continue; } else if (next.type == TOK_RBRACE) { break;