From: Brendan Hansen Date: Sat, 19 Jun 2021 02:07:55 +0000 (-0500) Subject: comments and tests X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=2069f7211db39247352de2802d72a11dc7957446;p=onyx.git comments and tests --- 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());