JSON.mapping
A simple JSON mapper inspired by Crystals JSON.mapping
Usage
require "json"
class Location
JSON.mapping(
lat: Float64,
lng: Float64,
)
end
class House
JSON.mapping(
address: String,
location: {type: Location, nilable: true},
)
end
house = House.from_json(%({"address": "Crystal Road 1234", "location": {"lat": 12.3, "lng": 34.5}}))
house.address
house.location
house.to_json
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/Kjarrigan/json-mapping.
License
The gem is available as open source under the terms of the MIT License.