I'm trying to expose a column which is saved in the DB as a JSON string. But it showed as just string. Any help would be appreciated.
Entity sample:
class Entity < Grape::Entity
expose :id
expose :name
expose :credentials # this is json string
end
Actual Response:
[
{
"id": 1,
"name": "Foo",
"credentials": "[{\"name\":\"key\",\"label\":\"Key\"},{\"name\":\"key2\",\"label\":\"Key2\"}]"
}
]
Expected Response:
[
{
"id": 1,
"name": "Foo",
"credentials": [
{
"name": "key",
"label": "Key"
},
{
"name": "key2",
"label":"Key2"
}
]
}
]