Question

I have a string defined in a controller @string which is already json formatted.

Now in my view.json.jbuilder, I try to only add this json output to my view and it doesn't seem to work as the json is always encoded (add / before every " chars).

I tried

json.some_node_name raw(@string)

And

json.some_node_name @string

Without success, any help?

Was it helpful?

Solution

Try

json.some_node_name JSON.parse(@string)

that way you parse the json, then re-make it into JSON. Not sure if jbuilder has a way of using pre-JSONified strings directly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top