magicjson
Version, currently master branch1 version
- master branchlatestDec 2, 2017
github.com/calebuharrison/magicjson
No description declared in shard.yml.
Installation
# Add this to your shard.yml
dependencies:
magicjson:
github: calebuharrison/magicjson
branch: mastermaster is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
0.22.0- License
- MIT
- Author
- Zatherz
Dependencies
This version declares no dependencies.
README
MagicJSON
A compiletime JSON parser generator for Crystal.
The main purpose that MagicJSON is supposed to fulfill is to make working with
payloads that need external Crystal data (i.e. objects not in the payload that
need to be passed all the way from from_json to an instance variable) painless,
or at least much less painful than with the builtin JSON.mapping.
MagicJSON also supports inheritance and mixins naturally. You can, for example, have a class that defines a field, a module that defines another field and another module that defines yet another field. If you extend that class and include both modules in another class you will have 3 fields.
Installation
Add this to your application's shard.yml:
dependencies:
magicjson:
gitlab: zatherz/magicjson
Usage
require "magicjson"
Define a User with a username and a bot? field:
require "magicjson"
struct User
include MagicJSON
json_defaults getter: true # MagicJSON supports customizable defaults!
field username : String
field bot? : Bool = true, key: "bot" # As opposed to JSON.mapping, you can also easily define fields ending in question marks or exclamation marks.
end
Examples
A couple of examples are available in the examples/ directory.
Documentation
Read the documentation online or build it with crystal docs.
Contributors
- Zatherz - creator, maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This branch
- Branch
master- Seen
- Dec 2, 2017
- Crystal
0.22.0- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/calebuharrison/magicjson
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 16, 2026
- Synced
- Aug 16, 2026
- Versions
- 1