I convert my hash to JSON using the Rails.to_json () method.
Hash:
{ "Größe" => "XL" }
JSON:
"{\"Gr\\u00f6\\u00dfe\":\"XL\"}"
After that, the JSON string is stored in the hstore (Postgres) column called static using this Rails (3.2.6) SQL command:
UPDATE ... "static" = 'options=>"{\"Gr\u00f6\u00dfe\":\"XL\"}"' WHERE ...
One backslash occurred.
In the database itself, the static column looks like this:
"options"=>"{\"Gru00f6u00dfe\":\"XL\"}"
All backslashes for u00f6 and u00dfe have disappeared.
JSON.parse () no longer identifies multibyte characters, so it returns the following hash:
{ "Gru00f6u00dfe" => "XL" }
Does anyone know how to prevent this? Thanks for any help!
source share