Ferdari Active Member Licensed User Longtime User Sep 14, 2020 #1 If i pass a string to my library it encodes some characters bad: B4X: Copy 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: Copy [{"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.
If i pass a string to my library it encodes some characters bad: B4X: Copy 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: Copy [{"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.
Erel B4X founder Staff member Licensed User Longtime User Sep 14, 2020 #2 1. There is no difference between B4A strings and Java strings. The URL encoding happens somewhere else. 2. The less you do in the library itself the better. No reason to create a json string in your library code.
1. There is no difference between B4A strings and Java strings. The URL encoding happens somewhere else. 2. The less you do in the library itself the better. No reason to create a json string in your library code.
Ferdari Active Member Licensed User Longtime User Sep 14, 2020 #3 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: Copy Gson gson = new GsonBuilder().disableHtmlEscaping().create();
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: Copy Gson gson = new GsonBuilder().disableHtmlEscaping().create();
Erel B4X founder Staff member Licensed User Longtime User Sep 14, 2020 #4 The less you do in the library itself the better. No reason to create a json string in your library code.
The less you do in the library itself the better. No reason to create a json string in your library code.
Ferdari Active Member Licensed User Longtime User Sep 14, 2020 #5 Erel said: The less you do in the library itself the better. No reason to create a json string in your library code. Click to expand... it are needed for a ContentProvider and it are handled by the lib.
Erel said: The less you do in the library itself the better. No reason to create a json string in your library code. Click to expand... it are needed for a ContentProvider and it are handled by the lib.