aboutsummaryrefslogtreecommitdiff
path: root/json.c
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2025-07-22 08:43:23 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2025-07-22 08:50:30 +0200
commite02bfc1854effe0bb55ea6d4320e2b1902eaeae3 (patch)
tree9c5402d2881a83d820dd1a7f1059fae1558cf875 /json.c
parent413cb3b0c5c70d60eee212c72afed9b5c659b6d8 (diff)
feat(json): Boolean parsing
Diffstat (limited to 'json.c')
-rw-r--r--json.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/json.c b/json.c
index 8a542f5..529dc3a 100644
--- a/json.c
+++ b/json.c
@@ -6,6 +6,7 @@
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
+#include <string.h>
#include "json.h"
#include "string.h"
@@ -190,6 +191,14 @@ parse_any_result parse_any(Arena *a, byte *src, uptr start_pos) {
parse_object_result object_result = parse_object(a, src, result.pos);
result.value->object = object_result.object;
result.pos = object_result.pos;
+ } else if (memcmp(src + result.pos, "true", 4) == 0) {
+ result.value->boolean = new(a, int, 1);
+ *result.value->boolean = 1;
+ result.pos = start_pos + 4;
+ } else if (memcmp(src + result.pos, "false", 5) == 0) {
+ result.value->boolean = new(a, int, 1);
+ *result.value->boolean = 0;
+ result.pos = start_pos + 5;
}
return result;