JSON - is there any XML CDATA equivalent?

↘锁芯ラ 提交于 2019-12-09 14:00:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!