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)
 

MicroDrie

Well-Known Member
Licensed User
Longtime User
The information given is very brief to help you.
You could start to convert the original json string to JSON tree online with Erel's tool at https://www.b4x.com/android/forum/threads/jscriptengine.35781/. Then you can see if the original JSON string is error-free and you have the correct code to edit the JSON strings.
 
Upvote 0

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
Thankyou very much, it solve the problem c: !
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…