Last active
November 4, 2021 06:59
-
-
Save MustafaFerhan/25906d2be6ca109f61ce to your computer and use it in GitHub Desktop.
Webview evaluateJavascript JSON problem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.gson.JsonParser; | |
/** | |
* Created by mustafaferhan on 22/05/15. | |
* | |
* When the working on webview.evaluateJavascript() method, it return as String on onReceiveValue() method. | |
* The problem is this String not convertable for JSON Object. | |
* Error Log: | |
* org.json.JSONException: Expected literal value at character 1 of or | |
* JSONException: Value of type java.lang.String cannot be converted to JSONObject | |
* | |
* Gson method is simple and clear. | |
* | |
*/ | |
public class StringUtil { | |
String getAsString (String param){ | |
JsonParser parser = new JsonParser(); | |
String retVal = parser.parse(param).getAsString(); | |
return retVal; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment