Java Question SOLVED Passing String to lib saves with bad characters

Ferdari

Active Member
Licensed User
If i pass a string to my library it encodes some characters bad:
B4X:
mylib.SaveStringToJson("https://play.google.com/store/apps/details?id=com.app")
This function saves a JSON file for library internal management, but inside some characters are changed like this:
B4X:
[{"androidPlayStoreLink":"https://play.google.com/store/apps/details?id\u003dcom.app"}]
The equal(=) symbol is changed to \u003d, in my lib the string is handled as Java String

I dont know if i need to set encoding or escape characters from B4A or from my Lib.

Help is very appreciated.
 

Ferdari

Active Member
Licensed User
SOLVED:
Youre right @Erel, the string are passing as is without encoding from B4A to Lib.
The problem was the GSON function that saves the JSON with html entities encoded by default, it should be disabled on build:
Java:
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
 
Top