We have a caching layer that stores json output of strings. I'd like to be able to put these strings into an array which I then transform to json via .to_json but it escapes all the previously encoded json. Is there a way to avoid this?
Here's a sample action to explain:
def index
a={name:"jon", email:"jon@domain.com"}.to_json
r={}
r[:users]=[]
r[:users] << a
render json: r.to_json
end
Outputs:
{"users":["{\"name\":\"jon\",\"email\":\"jon@domain.com\"}"]}
But I want:
{"users":["{"name":"jon","email":"jon@domain.com"}"]}
Though I am not showing it here, I'd be open to using ActiveModelSerializer (the 0.8 branch)
Edit
One possibility is doing a JSON.parse but obviously, that's a bit of a performance hit which I'd like to avoid.