{"id":13546054,"url":"https://github.com/jsonapi-serializer/jsonapi-serializer","last_synced_at":"2025-05-14T01:02:15.160Z","repository":{"id":38414757,"uuid":"212620037","full_name":"jsonapi-serializer/jsonapi-serializer","owner":"jsonapi-serializer","description":"A fast JSON:API serializer for Ruby (fork of Netflix/fast_jsonapi)","archived":false,"fork":false,"pushed_at":"2024-07-19T03:11:59.000Z","size":501,"stargazers_count":1420,"open_issues_count":67,"forks_count":144,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-05-09T22:01:51.555Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/jsonapi-serializer","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jsonapi-serializer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-03T15:57:42.000Z","updated_at":"2025-05-08T03:45:11.000Z","dependencies_parsed_at":"2024-10-29T10:57:25.354Z","dependency_job_id":null,"html_url":"https://github.com/jsonapi-serializer/jsonapi-serializer","commit_stats":{"total_commits":358,"total_committers":117,"mean_commits":"3.0598290598290596","dds":0.9050279329608939,"last_synced_commit":"55df2b712be38cc2adaa9cb7f7b9de59254d77f5"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsonapi-serializer%2Fjsonapi-serializer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsonapi-serializer%2Fjsonapi-serializer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsonapi-serializer%2Fjsonapi-serializer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jsonapi-serializer%2Fjsonapi-serializer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jsonapi-serializer","download_url":"https://codeload.github.com/jsonapi-serializer/jsonapi-serializer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253492529,"owners_count":21916959,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T12:00:30.723Z","updated_at":"2025-05-14T01:02:15.070Z","avatar_url":"https://github.com/jsonapi-serializer.png","language":"Ruby","readme":"# JSON:API Serialization Library\n\n## :warning: :construction: v2 (the `master` branch) is in maintenance mode! :construction: :warning:\n\nWe'll gladly accept bugfixes and security-related fixes for v2 (the `master` branch), but at this stage, contributions for new features/improvements are welcome only for v3. Please feel free to leave comments in the [v3 Pull Request](https://github.com/jsonapi-serializer/jsonapi-serializer/pull/141). \n\n---\n\nA fast [JSON:API](https://jsonapi.org/) serializer for Ruby Objects.\n\nPreviously this project was called **fast_jsonapi**, we forked the project\nand renamed it to **jsonapi/serializer** in order to keep it alive.\n\nWe would like to thank the Netflix team for the initial work and to all our\ncontributors and users for the continuous support!\n\n# Performance Comparison\n\nWe compare serialization times with `ActiveModelSerializer` and alternative\nimplementations as part of performance tests available at\n[jsonapi-serializer/comparisons](https://github.com/jsonapi-serializer/comparisons).\n\nWe want to ensure that with every\nchange on this library, serialization time stays significantly faster than\nthe performance provided by the alternatives. Please read the performance\narticle in the `docs` folder for any questions related to methodology.\n\n# Table of Contents\n\n* [Features](#features)\n* [Installation](#installation)\n* [Usage](#usage)\n  * [Rails Generator](#rails-generator)\n  * [Model Definition](#model-definition)\n  * [Serializer Definition](#serializer-definition)\n  * [Object Serialization](#object-serialization)\n  * [Compound Document](#compound-document)\n  * [Key Transforms](#key-transforms)\n  * [Collection Serialization](#collection-serialization)\n  * [Caching](#caching)\n  * [Params](#params)\n  * [Conditional Attributes](#conditional-attributes)\n  * [Conditional Relationships](#conditional-relationships)\n  * [Specifying a Relationship Serializer](#specifying-a-relationship-serializer)\n  * [Ordering `has_many` Relationship](#ordering-has_many-relationship)\n  * [Sparse Fieldsets](#sparse-fieldsets)\n  * [Using helper methods](#using-helper-methods)\n* [Performance Instrumentation](#performance-instrumentation)\n* [Deserialization](#deserialization)\n* [Migrating from Netflix/fast_jsonapi](#migrating-from-netflixfast_jsonapi)\n* [Contributing](#contributing)\n\n\n## Features\n\n* Declaration syntax similar to Active Model Serializer\n* Support for `belongs_to`, `has_many` and `has_one`\n* Support for compound documents (included)\n* Optimized serialization of compound documents\n* Caching\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'jsonapi-serializer'\n```\n\nExecute:\n\n```bash\n$ bundle install\n```\n\n## Usage\n\n### Rails Generator\nYou can use the bundled generator if you are using the library inside of\na Rails project:\n\n    rails g serializer Movie name year\n\nThis will create a new serializer in `app/serializers/movie_serializer.rb`\n\n### Model Definition\n\n```ruby\nclass Movie\n  attr_accessor :id, :name, :year, :actor_ids, :owner_id, :movie_type_id\nend\n```\n\n### Serializer Definition\n\n```ruby\nclass MovieSerializer\n  include JSONAPI::Serializer\n\n  set_type :movie  # optional\n  set_id :owner_id # optional\n  attributes :name, :year\n  has_many :actors\n  belongs_to :owner, record_type: :user\n  belongs_to :movie_type\nend\n```\n\n### Sample Object\n\n```ruby\nmovie = Movie.new\nmovie.id = 232\nmovie.name = 'test movie'\nmovie.actor_ids = [1, 2, 3]\nmovie.owner_id = 3\nmovie.movie_type_id = 1\nmovie\n\nmovies =\n  2.times.map do |i|\n    m = Movie.new\n    m.id = i + 1\n    m.name = \"test movie #{i}\"\n    m.actor_ids = [1, 2, 3]\n    m.owner_id = 3\n    m.movie_type_id = 1\n    m\n  end\n```\n\n### Object Serialization\n\n#### Return a hash\n```ruby\nhash = MovieSerializer.new(movie).serializable_hash\n```\n\n#### Return Serialized JSON\n```ruby\njson_string = MovieSerializer.new(movie).serializable_hash.to_json\n```\n\n#### Serialized Output\n\n```json\n{\n  \"data\": {\n    \"id\": \"3\",\n    \"type\": \"movie\",\n    \"attributes\": {\n      \"name\": \"test movie\",\n      \"year\": null\n    },\n    \"relationships\": {\n      \"actors\": {\n        \"data\": [\n          {\n            \"id\": \"1\",\n            \"type\": \"actor\"\n          },\n          {\n            \"id\": \"2\",\n            \"type\": \"actor\"\n          }\n        ]\n      },\n      \"owner\": {\n        \"data\": {\n          \"id\": \"3\",\n          \"type\": \"user\"\n        }\n      }\n    }\n  }\n}\n\n```\n\n#### The Optionality of `set_type`\nBy default fast_jsonapi will try to figure the type based on the name of the serializer class. For example `class MovieSerializer` will automatically have a type of `:movie`. If your serializer class name does not follow this format, you have to manually state the `set_type` at the serializer.\n\n### Key Transforms\nBy default fast_jsonapi underscores the key names. It supports the same key transforms that are supported by AMS. Here is the syntax of specifying a key transform\n\n```ruby\nclass MovieSerializer\n  include JSONAPI::Serializer\n\n  # Available options :camel, :camel_lower, :dash, :underscore(default)\n  set_key_transform :camel\nend\n```\nHere are examples of how these options transform the keys\n\n```ruby\nset_key_transform :camel # \"some_key\" =\u003e \"SomeKey\"\nset_key_transform :camel_lower # \"some_key\" =\u003e \"someKey\"\nset_key_transform :dash # \"some_key\" =\u003e \"some-key\"\nset_key_transform :underscore # \"some_key\" =\u003e \"some_key\"\n```\n\n### Attributes\nAttributes are defined using the `attributes` method.  This method is also aliased as `attribute`, which is useful when defining a single attribute.\n\nBy default, attributes are read directly from the model property of the same name.  In this example, `name` is expected to be a property of the object being serialized:\n\n```ruby\nclass MovieSerializer\n  include JSONAPI::Serializer\n\n  attribute :name\nend\n```\n\nCustom attributes that must be serialized but do not exist on the model can be declared using Ruby block syntax:\n\n```ruby\nclass MovieSerializer\n  include JSONAPI::Serializer\n\n  attributes :name, :year\n\n  attribute :name_with_year do |object|\n    \"#{object.name} (#{object.year})\"\n  end\nend\n```\n\nThe block syntax can also be used to override the property on the object:\n\n```ruby\nclass MovieSerializer\n  include JSONAPI::Serializer\n\n  attribute :name do |object|\n    \"#{object.name} Part 2\"\n  end\nend\n```\n\nAttributes can also use a different name by passing the original method or accessor with a proc shortcut:\n\n```ruby\nclass MovieSerializer\n  include JSONAPI::Serializer\n\n  attributes :name\n\n  attribute :released_in_year, \u0026:year\nend\n```\n\n### Links Per Object\nLinks are defined using the `link` method. By default, links are read directly from the model property of the same name. In this example, `public_url` is expected to be a property of the object being serialized.\n\nYou can configure the method to use on the object for example a link with key `self` will get set to the value returned by a method called `url` on the movie object.\n\nYou can also use a block to define a url as shown in `custom_url`. You can access params in these blocks as well as shown in `personalized_url`\n\n```ruby\nclass MovieSerializer\n  include JSONAPI::Serializer\n\n  link :public_url\n\n  link :self, :url\n\n  link :custom_url do |object|\n    \"https://movies.com/#{object.name}-(#{object.year})\"\n  end\n\n  link :personalized_url do |object, params|\n    \"https://movies.com/#{object.name}-#{params[:user].reference_code}\"\n  end\nend\n```\n\n#### Links on a Relationship\n\nYou can specify [relationship links](https://jsonapi.org/format/#document-resource-object-relationships) by using the `links:` option on the serializer. Relationship links in JSON API are useful if you want to load a parent document and then load associated documents later due to size constraints (see [related resource links](https://jsonapi.org/format/#document-resource-object-related-resource-links))\n\n```ruby\nclass MovieSerializer\n  include JSONAPI::Serializer\n\n  has_many :actors, links: {\n    self: :url,\n    related: -\u003e (object) {\n      \"https://movies.com/#{object.id}/actors\"\n    }\n  }\nend\n```\n\nRelationship links can also be configured to be defined as a method on the object.\n\n```ruby\n  has_many :actors, links: :actor_relationship_links\n```\n\nThis will create a `self` reference for the relationship, and a `related` link for loading the actors relationship later. NB: This will not automatically disable loading the data in the relationship, you'll need to do that using the `lazy_load_data` option:\n\n```ruby\n  has_many :actors, lazy_load_data: true, links: {\n    self: :url,\n    related: -\u003e (object) {\n      \"https://movies.com/#{object.id}/actors\"\n    }\n  }\n```\n\n### Meta Per Resource\n\nFor every resource in the collection, you can include a meta object containing non-standard meta-information about a resource that can not be represented as an attribute or relationship.\n\n\n```ruby\nclass MovieSerializer\n  include JSONAPI::Serializer\n\n  meta do |movie|\n    {\n      years_since_release: Date.current.year - movie.year\n    }\n  end\nend\n```\n\n#### Meta on a Relationship\n\nYou can specify [relationship meta](https://jsonapi.org/format/#document-resource-object-relationships) by using the `meta:` option on the serializer. Relationship meta in JSON API is useful if you wish to provide non-standard meta-information about the relationship.\n\nMeta can be defined either by passing a static hash or by using Proc to the `meta` key. In the latter case, the record and any params passed to the serializer are available inside the Proc as the first and second parameters, respectively.\n\n\n```ruby\nclass MovieSerializer\n  include JSONAPI::Serializer\n\n  has_many :actors, meta: Proc.new do |movie_record, params|\n    { count: movie_record.actors.length }\n  end\nend\n```\n\n### Compound Document\n\nSupport for top-level and nested included associations through `options[:include]`.\n\n```ruby\noptions = {}\noptions[:meta] = { total: 2 }\noptions[:links] = {\n  self: '...',\n  next: '...',\n  prev: '...'\n}\noptions[:include] = [:actors, :'actors.agency', :'actors.agency.state']\nMovieSerializer.new(movies, options).serializable_hash.to_json\n```\n\n### Collection Serialization\n\n```ruby\noptions[:meta] = { total: 2 }\noptions[:links] = {\n  self: '...',\n  next: '...',\n  prev: '...'\n}\nhash = MovieSerializer.new(movies, options).serializable_hash\njson_string = MovieSerializer.new(movies, options).serializable_hash.to_json\n```\n\n#### Control Over Collection Serialization\n\nYou can use `is_collection` option to have better control over collection serialization.\n\nIf this option is not provided or `nil` autodetect logic is used to try understand\nif provided resource is a single object or collection.\n\nAutodetect logic is compatible with most DB toolkits (ActiveRecord, Sequel, etc.) but\n**cannot** guarantee that single vs collection will be always detected properly.\n\n```ruby\noptions[:is_collection]\n```\n\nwas introduced to be able to have precise control this behavior\n\n- `nil` or not provided: will try to autodetect single vs collection (please, see notes above)\n- `true` will always treat input resource as *collection*\n- `false` will always treat input resource as *single object*\n\n### Caching\n\nTo enable caching, use `cache_options store: \u003ccache_store\u003e`:\n\n```ruby\nclass MovieSerializer\n  include JSONAPI::Serializer\n\n  # use rails cache with a separate namespace and fixed expiry\n  cache_options store: Rails.cache, namespace: 'jsonapi-serializer', expires_in: 1.hour\nend\n```\n\n`store` is required can be anything that implements a\n`#fetch(record, **options, \u0026block)` method:\n\n- `record` is the record that is currently serialized\n- `options` is everything that was passed to `cache_options` except `store`, so it can be everything the cache store supports\n- `\u0026block` should be executed to fetch new data if cache is empty\n\nSo for the example above it will call the cache instance like this:\n\n```ruby\nRails.cache.fetch(record, namespace: 'jsonapi-serializer', expires_in: 1.hour) { ... }\n```\n\n#### Caching and Sparse Fieldsets\n\nIf caching is enabled and fields are provided to the serializer, the fieldset will be appended to the cache key's namespace.\n\nFor example, given the following serializer definition and instance:\n```ruby\nclass ActorSerializer\n  include JSONAPI::Serializer\n\n  attributes :first_name, :last_name\n\n  cache_options store: Rails.cache, namespace: 'jsonapi-serializer', expires_in: 1.hour\nend\n\nserializer = ActorSerializer.new(actor, { fields: { actor: [:first_name] } })\n```\n\nThe following cache namespace will be generated: `'jsonapi-serializer-fieldset:first_name'`.\n\n### Params\n\nIn some cases, attribute values might require more information than what is\navailable on the record, for example, access privileges or other information\nrelated to a current authenticated user. The `options[:params]` value covers these\ncases by allowing you to pass in a hash of additional parameters necessary for\nyour use case.\n\nLeveraging the new params is easy, when you define a custom id, attribute or\nrelationship with a block you opt-in to using params by adding it as a block\nparameter.\n\n```ruby\nclass MovieSerializer\n  include JSONAPI::Serializer\n\n  set_id do |movie, params|\n    # in here, params is a hash containing the `:admin` key\n    params[:admin] ? movie.owner_id : \"movie-#{movie.id}\"\n  end\n\n  attributes :name, :year\n  attribute :can_view_early do |movie, params|\n    # in here, params is a hash containing the `:current_user` key\n    params[:current_user].is_employee? ? true : false\n  end\n\n  belongs_to :primary_agent do |movie, params|\n    # in here, params is a hash containing the `:current_user` key\n    params[:current_user]\n  end\nend\n\n# ...\ncurrent_user = User.find(cookies[:current_user_id])\nserializer = MovieSerializer.new(movie, {params: {current_user: current_user}})\nserializer.serializable_hash\n```\n\nCustom attributes and relationships that only receive the resource are still possible by defining\nthe block to only receive one argument.\n\n### Conditional Attributes\n\nConditional attributes can be defined by passing a Proc to the `if` key on the `attribute` method. Return `true` if the attribute should be serialized, and `false` if not. The record and any params passed to the serializer are available inside the Proc as the first and second parameters, respectively.\n\n```ruby\nclass MovieSerializer\n  include JSONAPI::Serializer\n\n  attributes :name, :year\n  attribute :release_year, if: Proc.new { |record|\n    # Release year will only be serialized if it's greater than 1990\n    record.release_year \u003e 1990\n  }\n\n  attribute :director, if: Proc.new { |record, params|\n    # The director will be serialized only if the :admin key of params is true\n    params \u0026\u0026 params[:admin] == true\n  }\n\n  # Custom attribute `name_year` will only be serialized if both `name` and `year` fields are present\n  attribute :name_year, if: Proc.new { |record|\n    record.name.present? \u0026\u0026 record.year.present?\n  } do |object|\n    \"#{object.name} - #{object.year}\"\n  end\nend\n\n# ...\ncurrent_user = User.find(cookies[:current_user_id])\nserializer = MovieSerializer.new(movie, { params: { admin: current_user.admin? }})\nserializer.serializable_hash\n```\n\n### Conditional Relationships\n\nConditional relationships can be defined by passing a Proc to the `if` key. Return `true` if the relationship should be serialized, and `false` if not. The record and any params passed to the serializer are available inside the Proc as the first and second parameters, respectively.\n\n```ruby\nclass MovieSerializer\n  include JSONAPI::Serializer\n\n  # Actors will only be serialized if the record has any associated actors\n  has_many :actors, if: Proc.new { |record| record.actors.any? }\n\n  # Owner will only be serialized if the :admin key of params is true\n  belongs_to :owner, if: Proc.new { |record, params| params \u0026\u0026 params[:admin] == true }\nend\n\n# ...\ncurrent_user = User.find(cookies[:current_user_id])\nserializer = MovieSerializer.new(movie, { params: { admin: current_user.admin? }})\nserializer.serializable_hash\n```\n\n### Specifying a Relationship Serializer\n\nIn many cases, the relationship can automatically detect the serializer to use.\n\n```ruby\nclass MovieSerializer\n  include JSONAPI::Serializer\n\n  # resolves to StudioSerializer\n  belongs_to :studio\n  # resolves to ActorSerializer\n  has_many :actors\nend\n```\n\nAt other times, such as when a property name differs from the class name, you may need to explicitly state the serializer to use.  You can do so by specifying a different symbol or the serializer class itself (which is the recommended usage):\n\n```ruby\nclass MovieSerializer\n  include JSONAPI::Serializer\n\n  # resolves to MovieStudioSerializer\n  belongs_to :studio, serializer: :movie_studio\n  # resolves to PerformerSerializer\n  has_many :actors, serializer: PerformerSerializer\nend\n```\n\nFor more advanced cases, such as polymorphic relationships and Single Table Inheritance, you may need even greater control to select the serializer based on the specific object or some specified serialization parameters. You can do by defining the serializer as a `Proc`:\n\n```ruby\nclass MovieSerializer\n  include JSONAPI::Serializer\n\n  has_many :actors, serializer: Proc.new do |record, params|\n    if record.comedian?\n      ComedianSerializer\n    elsif params[:use_drama_serializer]\n      DramaSerializer\n    else\n      ActorSerializer\n    end\n  end\nend\n```\n\n### Ordering `has_many` Relationship\n\nYou can order the `has_many` relationship by providing a block:\n\n```ruby\nclass MovieSerializer\n  include JSONAPI::Serializer\n\n  has_many :actors do |movie|\n    movie.actors.order(position: :asc)\n  end\nend\n```\n\n### Sparse Fieldsets\n\nAttributes and relationships can be selectively returned per record type by using the `fields` option.\n\n```ruby\nclass MovieSerializer\n  include JSONAPI::Serializer\n\n  attributes :name, :year\nend\n\nserializer = MovieSerializer.new(movie, { fields: { movie: [:name] } })\nserializer.serializable_hash\n```\n\n### Using helper methods\n\nYou can mix-in code from another ruby module into your serializer class to reuse functions across your app.\n\nSince a serializer is evaluated in a the context of a `class` rather than an `instance` of a class, you need to make sure that your methods act as `class` methods when mixed in.\n\n\n##### Using ActiveSupport::Concern\n\n``` ruby\n\nmodule AvatarHelper\n  extend ActiveSupport::Concern\n\n  class_methods do\n    def avatar_url(user)\n      user.image.url\n    end\n  end\nend\n\nclass UserSerializer\n  include JSONAPI::Serializer\n\n  include AvatarHelper # mixes in your helper method as class method\n\n  set_type :user\n\n  attributes :name, :email\n\n  attribute :avatar do |user|\n    avatar_url(user)\n  end\nend\n\n```\n\n##### Using Plain Old Ruby\n\n``` ruby\nmodule AvatarHelper\n  def avatar_url(user)\n    user.image.url\n  end\nend\n\nclass UserSerializer\n  include JSONAPI::Serializer\n\n  extend AvatarHelper # mixes in your helper method as class method\n\n  set_type :user\n\n  attributes :name, :email\n\n  attribute :avatar do |user|\n    avatar_url(user)\n  end\nend\n\n```\n\n### Customizable Options\n\nOption | Purpose | Example\n------------ | ------------- | -------------\nset_type | Type name of Object | `set_type :movie`\nkey | Key of Object | `belongs_to :owner, key: :user`\nset_id | ID of Object | `set_id :owner_id` or `set_id { \\|record, params\\| params[:admin] ? record.id : \"#{record.name.downcase}-#{record.id}\" }`\ncache_options | Hash with store to enable caching and optional further cache options | `cache_options store: ActiveSupport::Cache::MemoryStore.new, expires_in: 5.minutes`\nid_method_name | Set custom method name to get ID of an object (If block is provided for the relationship, `id_method_name` is invoked on the return value of the block instead of the resource object) | `has_many :locations, id_method_name: :place_ids`\nobject_method_name | Set custom method name to get related objects | `has_many :locations, object_method_name: :places`\nrecord_type | Set custom Object Type for a relationship | `belongs_to :owner, record_type: :user`\nserializer | Set custom Serializer for a relationship | `has_many :actors, serializer: :custom_actor`, `has_many :actors, serializer: MyApp::Api::V1::ActorSerializer`, or `has_many :actors, serializer -\u003e (object, params) { (return a serializer class) }`\npolymorphic | Allows different record types for a polymorphic association | `has_many :targets, polymorphic: true`\npolymorphic | Sets custom record types for each object class in a polymorphic association | `has_many :targets, polymorphic: { Person =\u003e :person, Group =\u003e :group }`\n\n### Performance Instrumentation\n\nPerformance instrumentation is available by using the\n`active_support/notifications`.\n\nTo enable it, include the module in your serializer class:\n\n```ruby\nrequire 'jsonapi/serializer'\nrequire 'jsonapi/serializer/instrumentation'\n\nclass MovieSerializer\n  include JSONAPI::Serializer\n  include JSONAPI::Serializer::Instrumentation\n\n  # ...\nend\n```\n\n[Skylight](https://www.skylight.io/) integration is also available and\nsupported by us, follow the Skylight documentation to enable it.\n\n### Running Tests\nThe project has and requires unit tests, functional tests and performance\ntests. To run tests use the following command:\n\n```bash\nrspec\n```\n\n## Deserialization\nWe currently do not support deserialization, but we recommend to use any of the next gems:\n\n### [JSONAPI.rb](https://github.com/stas/jsonapi.rb)\n\nThis gem provides the next features alongside deserialization:\n- Collection meta\n- Error handling\n- Includes and sparse fields\n- Filtering and sorting\n- Pagination\n\n## Migrating from Netflix/fast_jsonapi\n\nIf you come from [Netflix/fast_jsonapi](https://github.com/Netflix/fast_jsonapi), here is the instructions to switch.\n\n### Modify your Gemfile\n\n```diff\n- gem 'fast_jsonapi'\n+ gem 'jsonapi-serializer'\n```\n\n### Replace all constant references\n\n```diff\nclass MovieSerializer\n- include FastJsonapi::ObjectSerializer\n+ include JSONAPI::Serializer\nend\n```\n\n### Replace removed methods\n\n```diff\n- json_string = MovieSerializer.new(movie).serialized_json\n+ json_string = MovieSerializer.new(movie).serializable_hash.to_json\n```\n\n### Replace require references\n\n```diff\n- require 'fast_jsonapi'\n+ require 'jsonapi/serializer'\n```\n\n### Update your cache options\n\nSee [docs](https://github.com/jsonapi-serializer/jsonapi-serializer#caching).\n\n```diff\n- cache_options enabled: true, cache_length: 12.hours\n+ cache_options store: Rails.cache, namespace: 'jsonapi-serializer', expires_in: 1.hour\n```\n\n## Contributing\n\nPlease follow the instructions we provide as part of the issue and\npull request creation processes.\n\nThis project is intended to be a safe, welcoming space for collaboration, and\ncontributors are expected to adhere to the\n[Contributor Covenant](https://contributor-covenant.org) code of conduct.\n","funding_links":[],"categories":["Ruby Gems","Ruby","API Builder and Discovery","Serializers"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsonapi-serializer%2Fjsonapi-serializer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjsonapi-serializer%2Fjsonapi-serializer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjsonapi-serializer%2Fjsonapi-serializer/lists"}