json_mapping
Version, currently 0.1.12 versions
- 0.1.1latestApr 10, 2021
- 0.1.0not indexedJan 7, 2025
github.com/crystal-lang/json_mapping.cr
Provides the legacy `JSON.mapping` macro method
20 stars
5 dependents
License: MIT
Installation
# Add this to your shard.yml
dependencies:
json_mapping:
github: crystal-lang/json_mapping.cr
version: ~> 0.1.1Then run:
shards installshard.yml
- Crystal
>= 0.34.0, < 2.0.0- License
- MIT
- Author
- Brian J. Cardiff <bcardiff@manas.tech>
Dependencies
This version declares no dependencies.
README
# json_mapping
Provides the legacy `JSON.mapping` macro method.
This shard is provided as-is and considered deprecated. It won't receive feature enhancements.
Please consider using [`JSON::Serializable`](https://crystal-lang.org/api/latest/JSON/Serializable.html) instead, the successor included in Crystal's standard library.
## Installation
1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
json_mapping:
github: crystal-lang/json_mapping.cr
```
2. Run `shards install`
## Usage
```crystal
require "json_mapping"
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 # => "Crystal Road 1234"
house.location # => #<Location:0x10cd93d80 @lat=12.3, @lng=34.5>
house.to_json # => %({"address":"Crystal Road 1234","location":{"lat":12.3,"lng":34.5}})
houses = Array(House).from_json(%([{"address": "Crystal Road 1234", "location": {"lat": 12.3, "lng": 34.5}}]))
houses.size # => 1
houses.to_json # => %([{"address":"Crystal Road 1234","location":{"lat":12.3,"lng":34.5}}])
```
## Contributing
1. Fork it (<https://github.com/crystal-lang/json_mapping.cr/fork>)
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.1- Tagged
- Apr 10, 2021
- Commit
7e063bd5af85- Crystal
>= 0.34.0, < 2.0.0- Indexed
- yes
Dependents
Repository
github.com/crystal-lang/json_mapping.cr
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 12, 2026
- Synced
- Aug 12, 2026
- Versions
- 2