I have no idea why embedded json would be considered worse than the
rest of the page that is sent down. I do it all the time, usually with
small items though, so I haven't have the problem you are describing.
I was hoping that someone would have a suggestion of a built in method
to call.

I've had to do this in a helper that was constructing a complicated
object, and I think this is similar to your problem:

1) enumerate through all the parts of your object that could contain
dangerous  data and call h() on them.
2) call raw(your_object.to_json) on the result.

It's definitely not an easy, generic solution, but it gets you past
this problem.

On Fri, Aug 26, 2011 at 8:22 AM, Robert Walker <li...@ruby-forum.com> wrote:
> Alex Duck wrote in post #1018609:
>> Is there no easy way to embed HTML safe JSON in an HTML document, and
>> have
>> it parsed by JavaScript engine at the same time?
>
> You could Base64 encode the JSON and decode it on the client-side with
> JavaScript.
>
> I am ABSOLUTELY NOT recommending that you do this, but simply stating
> that it could work. Still a bad design idea IMHO.
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to