Java Question SOLVED Passing String to lib saves with bad characters

Ferdari

Active Member
Licensed User
Longtime 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
Longtime 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();
 

Ferdari

Active Member
Licensed User
Longtime User
The less you do in the library itself the better. No reason to create a json string in your library code.
it are needed for a ContentProvider and it are handled by the lib.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…