问题
I'm looking for a way that json parsing will take information as is (as if it was CDATA) - and not to try to serialize that. We use both .net and java (client and server) - so the answer should be about JSON structure Is there any way to achieve this structure?
Thanks.
回答1:
There is no XML CDATA equivalent in JSON. But you can encode your message in a string literal using something like base64. See this question for more details.
回答2:
http://www.json.org/ describes JSON format in details. According to it JSON doesn't support "something like CDATA" value type.
To achieve CDATA structure you can apply custom logic to handle string based values (and do it in the same way both for .net and java implementations). E.g.
{
"type" : "CDATA",
"value" : "Value that I will handle with my custom logic on java and .net side"
}
来源:https://stackoverflow.com/questions/14935866/json-is-there-any-xml-cdata-equivalent