Reputation: 710
Json is supposed to be able to be parsed with UTF characters included.
In particular I'm talking about -
. Or as it seems to be getting encoded: \u2013
This is for a json api output, and there's no need to be escaping these &
's that are in text fields. I wonder, how do people usually handle this in Rails 3?
Upvotes: 2
Views: 1257
Reputation: 87
You can replace \u2013
with -
in your string before writing it into JSON:
string = '\u2013'
string2 = string.gsub('\u2013', '-')
puts(string2) #Will output '-'
After, you can write string2
into yout JSON file.
Upvotes: 0