1
When inserting an html content into an obj Json
He is inserting a \
next to all closing tags bars.
example:
input: obj.put("html","< head>< / head>"):
output: "< head>< \/ head>"
How can I ignore and insert nothing into this bar Json
?
1
When inserting an html content into an obj Json
He is inserting a \
next to all closing tags bars.
example:
input: obj.put("html","< head>< / head>"):
output: "< head>< \/ head>"
How can I ignore and insert nothing into this bar Json
?
1
Hello don’t worry about this character, when decoding the JSON
the system will remove it:
Follow an example on java
:
public static void main(String[] args) {
try {
JSONObject jsonObject = new JSONObject();
jsonObject.put("head","<head></head>");
jsonObject.put("body","<body></body>");
jsonObject.put("script","<script></script>");
JSONObject novo = new JSONObject(jsonObject.toString());
System.out.println(novo.get("head"));
System.out.println(novo.get("body"));
System.out.println(novo.get("script"));
} catch (JSONException e) {
e.printStackTrace();
}
}
See that it will print without the character!
Follow an example on Javascript
, used the result mounted by java
:
<html>
<head>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript">
var obj = jQuery.parseJSON( '{"head":"<head><\/head>","body":"<body><\/body>","script":"<script><\/script>"}' );
alert( obj.head);
alert( obj.body);
alert( obj.script);
</script>
</head>
</html>
Here too the character is removed!
Browser other questions tagged java json
You are not signed in. Login or sign up in order to post.
Welcome to Stack Overflow! In order for the community to help you, it is important that you explain in detail your problem and show the code you made. I suggest I read the articles: Tour and how to ask a question.
– Thiago Luiz Domacoski