askn / crystal-by-example

Crystal By Example

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Example JSON

Ivo-Balbaert opened this issue · comments

result = String.build do |io|
io.json_object do |object|
object.field "address", "Crystal Road 1234"
object.field "location" do
io.json_array do |array|
array << 12.3
array << 34.5
end
end
end
end

Error: undefined method json_object for String::Builder

This doesn't seem to relevant anymore as the original example has been changed:

result = JSON.build do |json|
json.object do
json.field "address", "Crystal Road 1234"
json.field "location" do
json.array do
json.number 12.3
json.number 34.5
end
end
end
end