Load a JSON string into a data structure.
Also, create a new data structure and serialize it into JSON.

Use objects and arrays (as appropriate for your language)
and make sure your JSON is valid (https://jsonformatter.org).

 
require "json_mapping"
 
class Foo
  JSON.mapping(
    num: Int64,
    array: Array(String),
  )
end
 
def json
  foo = Foo.from_json(%({"num": 1, "array": ["a", "b"]}))
  puts("#{foo.num} #{foo.array}")
  puts(foo.to_json)
end
 