json_mapping
Version, currently 0.1.02 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
Nothing has been indexed for 0.1.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
json_mapping:
github: crystal-lang/json_mapping.cr
version: ~> 0.1.0Then run:
shards installshard.yml
No shard.yml has been indexed for 0.1.0. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
# 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.0- Tagged
- Jan 7, 2025
- Commit
128c6e1a2675- Indexed
- not yet
Dependents
Repository
github.com/crystal-lang/json_mapping.cr
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 12, 2026
- Synced
- Aug 12, 2026
- Versions
- 2