How to convert a string to a JSON object that I'll use inside JSNI? Thank you.
2 Answers
This is a copy-paste way to do it:
import com.google.gwt.core.client.JsonUtils;
import com.google.gwt.json.client.JSONArray;
import com.google.gwt.json.client.JSONObject;
...
JSONObject data = new JSONObject(JsonUtils.safeEval(jsonString));
JSONArray array = data.get("anArray").isArray();
JSONObject obj = data.get("anObject").isObject();
Comments
You should look at gwt core JsonUtils which has a safeEval method for the string. You should define a JavaScript Overlay Object for use with the result or you could work with the object in JSNI as you seem to want to.
1 Comment
Abdessamad Doughri
Thanks! I resolved this using JSON.parse() inside JSNI