Conveniently deserialize JSON API payloads into custom hashes.
Go to file
2024-04-28 12:14:05 +03:00
lib/jsonapi Fix deserialization bug in JSONAPI deserializable resource 2024-04-28 12:14:05 +03:00
spec Make resource deserialization local. (#17) 2017-07-25 07:56:40 +02:00
.gitignore Initial commit 2016-10-26 05:37:57 +02:00
.hound.yml Make HoundCI use rubocop config. 2016-11-22 22:04:57 +01:00
.rubocop.yml Whitelist has_many and has_one in rubocop. (#8) 2016-11-22 21:28:14 +01:00
.travis.yml Initial commit 2016-10-26 05:37:57 +02:00
Gemfile Initial commit 2016-10-26 05:37:57 +02:00
jsonapi-deserializable.gemspec Remove jsonapi-parser dependency. (#14) 2017-07-25 07:45:36 +02:00
LICENSE Create LICENSE 2017-09-13 15:17:52 +02:00
Rakefile Initial commit 2016-10-26 05:37:57 +02:00
README.md Updated README 2023-02-13 23:25:23 +03:00
VERSION Prepare for v0.2.0 release 2017-07-25 08:15:12 +02:00

jsonapi-deserializable

Ruby gem for deserializing JSON API payloads into custom hashes.

Usage

Support for included documents

To insert the included documents to has_one and has_many relation ship, use the with_included: true option to the relationship:

class DeserializableBook < JSONAPI::Deserializable::Resource
    id
    type
    attributes :id,
               :title

    has_one :author, with_included: true
end

To use a custom deserializer for the included relationship, use the deserializer option:

class DeserializableBook < JSONAPI::Deserializable::Resource
    id
    type
    attributes :id,
               :title

    has_one :author, with_included: true, deserializer: DeserialzableAuthor
end

If the property name is different than the included object type, pass the type option:

class DeserializableBook < JSONAPI::Deserializable::Resource
    id
    type
    attributes :id,
               :title

    has_one :author, with_included: true, deserializer: DeserializablePerson, type: 'people'
end

Status

Gem Version Build Status codecov Gitter chat

Resources

Usage and documentation

See jsonapi-rb.org/guides/deserialization.

License

jsonapi-deserializable is released under the MIT License.