JSON output replacing & with "\u0026 "

Hi,

I’m outputting some database objects as static JSON files using a stand
along ruby script.rb, that other could run outside of my rails app. When
I use this script, the output replaces “&” with “\u0026.” If I use the
same code to output my JSON files in console, it outputs fine.

I imagine there is some gem or something I’m not including in my
script.rb that would resolve this. Thoughts?

Thanks!

On Oct 10, 3:42 pm, Mario Gr [email protected] wrote:

Hi,

I’m outputting some database objects as static JSON files using a stand
along ruby script.rb, that other could run outside of my rails app. When
I use this script, the output replaces “&” with “\u0026.” If I use the
same code to output my JSON files in console, it outputs fine.

I imagine there is some gem or something I’m not including in my
script.rb that would resolve this. Thoughts?

If you’re using ActiveSupport’s json stuff then
ActiveSupport::JSON::Encoding.escape_html_entities_in_json controls
this (although
\u0026 is perfectly u legal way of representing &)

Fred