Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions spec/std/json/serialization_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ describe "JSON serialization" do
Path.from_json(%("foo/bar")).should eq(Path.new("foo/bar"))
end

it "does Path.from_json_object_key" do
Hash(Path, String).from_json(%({"foo/bar": "baz"})).should eq({Path.new("foo/bar") => "baz"})
end

{% for int in BUILTIN_INTEGER_TYPES %}
it "does {{ int }}.from_json" do
{{ int }}.from_json("0").should(be_a({{ int }})).should eq(0)
Expand Down
4 changes: 4 additions & 0 deletions src/json/from_json.cr
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ def String.from_json_object_key?(key : String) : String
key
end

def Path.from_json_object_key?(key : String) : Path
new(key)
end

def Array.new(pull : JSON::PullParser)
ary = new
new(pull) do |element|
Expand Down