B4J Question losing character when using File.WriteString

I need to save a json file to read after. but when it save de file, it lose two essential character. This is the part of the file that i send:

"key": "value<br><font size = \"1\">value</font>",

And this is what it goes to the file:

"key": "value<br><font size = "1">value</font>",

It loses the two "\" next to the 1. In the code, I am using this command:

File.WriteString(File.DirApp,"file_name.json",value)
 

William Lancee

Well-Known Member
Licensed User
Longtime User
The backslash indicates that the next character should treated "as is" (not as a special character).
This is called escaping. If you want to keep the slash, then escape that by doubling it.
You'll still have to escape the quotes.

"key": "value<br><font size =\\\"1\\\">value</font>"
 
Upvote 0
The backslash indicates that the next character should treated "as is" (not as a special character).
This is called escaping. If you want to keep the slash, then escape that by doubling it.
You'll still have to escape the quotes.

"key": "value<br><font size =\\\"1\\\">value</font>"
Thankyou very much, it solve the problem c: !
 
Upvote 0
Top