fix json child parsing issue

This commit is contained in:
jacob 2024-04-03 15:28:04 -05:00
parent 4978ec6633
commit 369223eafd

View File

@ -5,7 +5,6 @@
#include "math.h"
/* Non-standard-conforming JSON parser.
* - Unicode not supported (TODO)
* - Unicode escape sequences in strings (\u) not supported
* - Leading 0s in numbers are allowed
*/
@ -787,7 +786,7 @@ INTERNAL void parse(struct arena *arena, struct parser *p)
++stack_count;
/* Create child & push to stack */
struct json *child = arena_push(arena, struct json);
struct json *child = arena_push_zero(arena, struct json);
child->parent = json;
*arena_push(scratch.arena, struct json *) = child;
++stack_count;
@ -795,7 +794,7 @@ INTERNAL void parse(struct arena *arena, struct parser *p)
/* Check for comma */
if (at->type == TOKEN_TYPE_COMMA) {
/* Create sibling & push to stack */
struct json *sibling = arena_push(arena, struct json);
struct json *sibling = arena_push_zero(arena, struct json);
sibling->parent = parent_json;
*arena_push(scratch.arena, struct json *) = sibling;
++stack_count;