aboutsummaryrefslogtreecommitdiff
path: root/core/encoding/json/parser.odin
diff options
context:
space:
mode:
authorjockus <joakim.hentula@gmail.com>2020-09-15 11:39:34 +0100
committerjockus <joakim.hentula@gmail.com>2020-09-15 11:39:34 +0100
commit195dbd658dd5518ab10c8f143f477d0e29dc751e (patch)
treeae6c6bc21cf972ef25406f4f2ee2704dbe9d17e1 /core/encoding/json/parser.odin
parent0cd681e6b76896e671d11007966b118b2b263e39 (diff)
Added option to parse number as integer, disabled by default
Diffstat (limited to 'core/encoding/json/parser.odin')
-rw-r--r--core/encoding/json/parser.odin9
1 files changed, 5 insertions, 4 deletions
diff --git a/core/encoding/json/parser.odin b/core/encoding/json/parser.odin
index 04e2bab09..448a0e41f 100644
--- a/core/encoding/json/parser.odin
+++ b/core/encoding/json/parser.odin
@@ -11,11 +11,12 @@ Parser :: struct {
spec: Specification,
allocator: mem.Allocator,
unmarshal_data: any,
+ parse_integers: bool,
}
-make_parser :: proc(data: []byte, spec := Specification.JSON, allocator := context.allocator) -> Parser {
+make_parser :: proc(data: []byte, spec := Specification.JSON, parse_integers := false, allocator := context.allocator) -> Parser {
p: Parser;
- p.tok = make_tokenizer(data, spec);
+ p.tok = make_tokenizer(data, spec, parse_integers);
p.spec = spec;
p.allocator = allocator;
assert(p.allocator.procedure != nil);
@@ -23,9 +24,9 @@ make_parser :: proc(data: []byte, spec := Specification.JSON, allocator := conte
return p;
}
-parse :: proc(data: []byte, spec := Specification.JSON, allocator := context.allocator) -> (Value, Error) {
+parse :: proc(data: []byte, spec := Specification.JSON, parse_integers := false, allocator := context.allocator) -> (Value, Error) {
context.allocator = allocator;
- p := make_parser(data, spec, allocator);
+ p := make_parser(data, spec, parse_integers, allocator);
if p.spec == Specification.JSON5 {
return parse_value(&p);