From 2069f7211db39247352de2802d72a11dc7957446 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Fri, 18 Jun 2021 21:07:55 -0500 Subject: [PATCH] comments and tests --- modules/json/encoder.onyx | 6 ++++-- modules/json/example.onyx | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/json/encoder.onyx b/modules/json/encoder.onyx index df5dd013..8747e968 100644 --- a/modules/json/encoder.onyx +++ b/modules/json/encoder.onyx @@ -66,7 +66,7 @@ encode :: #match { for i: v.entries.count { if i > 0 do io.write_byte(w, #char ","); - entry := v.entries[i]; + entry := ^v.entries[i]; io.write_escaped_str(w, entry.key); io.write_byte(w, #char ":"); @@ -113,7 +113,9 @@ encode :: #match { return .None; }, - + // This is disabled because I would prefer to have a compile time error for an unsupported type, + // as opposed to a error to check programatically. + // // // Inserted after any of the #add_match directives // #precedence 1000 (w: ^io.Writer, v: $T) -> Encoding_Error { // return .Unsupported_Type; diff --git a/modules/json/example.onyx b/modules/json/example.onyx index 37db4715..7306cf69 100644 --- a/modules/json/example.onyx +++ b/modules/json/example.onyx @@ -5,7 +5,7 @@ use package core json :: package json -json_string := "{ \"test\": \"\\tHello,\\n\\\"World!\\\"\", \"array\": [1,2,3,4,5,1423], \"sub\": { \"mem\": true } }"; +json_string := "{ \"test\": \"\\tHello,\\n\\\"World!\\\"\", \"array\": [1,2,3,4,5,1423], \"sub\": { \"mem\": true, \"other\": null } }"; main :: (args: [] cstr) { arena := alloc.arena.make(context.allocator, 4096); @@ -20,7 +20,7 @@ main :: (args: [] cstr) { // println(v["friends"][1]["name"]->as_str()); // } - #if false { + #if true { value := decoded_json.root["array"]; for v: value->as_array() { println(v->as_int()); -- 2.25.1