Search code examples
ruby-on-railsjsonactive-model-serializersfastjsonapi

how to change response format from fast_jsonapi format to AMS gem response format


I want to change The response format of fast_jsonapi gem from:

{
    "data": {
        "id": "8",
        "type": "directory",
        "attributes": {
            "firstname": "Naoufal",
            "lastname": "Huster",
        }
    }
}

To this:

{
  "id": "8",
  "firstname": "Naoufal",
  "lastname": "Huster",
}

I'm migrating from using AMS gem to using fast_jsonapi, I want to use fast_jsonapi but keep the same response json format of AMS when rendering data.

Ruby 2.5.0 Rails 5.2.1 fast_jsonapi gem


Solution

  • I think this is not possible. fastjson_api gem follows the json api standard.

    Also, a similar question was asked in the repo: source