From 3d8af6e93dfedcf2fa4e37adbece58dccaba168a Mon Sep 17 00:00:00 2001 From: Matthew Hall Date: Mon, 27 Mar 2023 23:44:34 +1300 Subject: Finish up JSON parsing example --- spec/practical/json_spec.cr | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'spec/practical') diff --git a/spec/practical/json_spec.cr b/spec/practical/json_spec.cr index 7a2875f..79d60dd 100644 --- a/spec/practical/json_spec.cr +++ b/spec/practical/json_spec.cr @@ -2,8 +2,6 @@ require "../spec_helper" include Parcom -# NOTE: WORK IN PROGRESS - alias JSONType = Nil \ | Bool \ | Int64 \ @@ -412,6 +410,14 @@ describe "example: JSON parsing" do result.tokens.empty?.should be_true end end + + it "parses objects" do + {"{}", "{\"foo\": 1}"}.each do |s| + result = json_value.parse(Tokens.from_string(s)) + result.value.data.should be_a(Hash(String, JSONValue)) + result.tokens.empty?.should be_true + end + end end end -- cgit v1.2.1