Input XML fragment:
<organizationStateParty>Acme (ME / 74)</organizationStateParty>
Resultant JSON:
"organizationStateParty":"Acme (ME \/ 74)"
Online tools don't do it.
Also, what are the valid values for the Format property on this policy? It's not documented and its just a string in the Schema.
Thanks, Kurt
Solved! Go to Solution.
Dear @Kurt Kanaskie ,
Those backslashes are escape characters. They are escaping the special characters inside of the string associated with JSON response.
You have to use JSON.parse
to parse that JSON string into a JSON object.
For example, below url will have backward slashes if it's a raw JSON string. The same url if you convert into object using JSON.parse or install chrome browser plugin like JSON viewer you will never see them.
Cheers,
Anil Sagar
Dear @Kurt Kanaskie ,
Those backslashes are escape characters. They are escaping the special characters inside of the string associated with JSON response.
You have to use JSON.parse
to parse that JSON string into a JSON object.
For example, below url will have backward slashes if it's a raw JSON string. The same url if you convert into object using JSON.parse or install chrome browser plugin like JSON viewer you will never see them.
Cheers,
Anil Sagar
Some more discussion regarding same here..
Hi Anil,
Thanks for your response, I must be missing something obvious.
In my scenario, my node app is returning results from a backend DB. I convert that JSON result into XML using JSON-to-XML, run an XSLT, then convert back using XML-to-JSON. I don't want the string to be modified.
I understand if the JSON had a value that included angle brackets, JSON-to-XML converts that to "<uhoh&gt;" in the XML text and XML-to-JSON converts that back to the angle brackets (at least in the online tool: http://www.utilities-online.info/xmltojson). I see how those are equivalent.
Consider this in node:
$ node --version v0.10.31 > var tmp = { ... "root": { ..... "el1": "name (code / number)", ..... "el2": "http://www.something", ..... "el3": "<uhoh> this could be trouble" ..... } ... } > tmp { root: { el1: 'name (code / number)', el2: 'http://www.something', el3: '<uhoh> this could be trouble' } } > JSON.stringify(tmp) '{"root":{"el1":"name (code / number)","el2":"http://www.something","el3":"<uhoh> this could be trouble"}}' > JSON.parse(JSON.stringify(tmp)) { root: { el1: 'name (code / number)', el2: 'http://www.something', el3: '<uhoh> this could be trouble' } }
Seems to deal with the slash just fine.
Thanks, Kurt
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |