jsonapi-serializer/docs/json_serialization.md
Kapil Sachdev c32358ecf5 fix: Rename FastJsonapi::ObjectSerializer to JSONAPI::Serializer
As the project has been renamed, its better to reflect it in the source 
code as well.
JSONAPI::Serializer is evaluated from FastJsonapi::ObjectSerializer so 
this change  probably will go unnoticed in gem usage.
2020-08-27 10:57:15 +01:00

706 B

JSON Serialization Support

Support for JSON serialization is no longer provided as part of the API of fast_jsonapi. This decision (see #12) is based on the idea that developers know better what library for JSON serialization works best for their project.

To bring back the old functionality, define the to_json or serialized_json methods with the relevant JSON library call. Here's an example on how to get it working with the popular oj gem:

require 'oj'
require 'fast_jsonapi'

class BaseSerializer
  include JSONAPI::Serializer

  def to_json
    Oj.dump(serializable_hash)
  end
  alias_method :serialized_json, :to_json
end

class MovieSerializer < BaseSerializer
  # ...
end