yosiat / panko_serializer

High Performance JSON Serialization for ActiveRecord & Ruby Objects
https://panko.dev
MIT License
592 stars 36 forks source link

Adding a custom root name for array serializer #105

Open sarah-mica opened 3 years ago

sarah-mica commented 3 years ago

In ActiveModelSerializer you can specify a custom root name for an array like so:

render json :@items, root: 'custom item list'

With the following result:

{
  "custom item list": [
    {
      "item_id": 1,
      "item name": "item 1"
    },
    {
      "item_id": 2,
      "item_name": "item 2"
    }
  ]
}

Is there any way do this in panko??

yosiat commented 3 years ago

Hi @sarah-mica ,

Specifying root name is not supported in Panko as of today.

I'll try to give it a check next weekend.