Pergunta

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?

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top