Currently, I am developing a JavaScript script that is executed using windows cscript.exe
. The purpose of my script is to load a JSON object from a file, add a parameter, and then save it back to the file (I am utilizing the json2.min.js implementation).
To parse the text into a JSON object, I am using JSON.parse(text)
, and for creating the string that is written back, I use JSON.stringify(text, null, 3)
. Everything works smoothly until I come across Unicode encoding.
Within the file, there are specific values such as
"someKey": "\u003Ca href=\"http://www.something.com\"\u003E"
Which after being read and saved back to the file (stringify
), get changed to:
"someKey": "< a href=\"http://www.something.com\">
There are several other foreign Unicode characters that undergo conversion.
My main concern is how can I preserve the original encoding when carrying out the stringify
operation?
Is there any function available for conversion that I can implement during or post stringify
?