Skip to content

Conveniently deserialize JSON API payloads into custom hashes.

License

Notifications You must be signed in to change notification settings

ditkrg/jsonapi-deserializable

 
 

Repository files navigation

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.

About

Conveniently deserialize JSON API payloads into custom hashes.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%