3

How to convert a string to a JSON object that I'll use inside JSNI? Thank you.

2 Answers 2

4

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();
Sign up to request clarification or add additional context in comments.

Comments

1

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

Thanks! I resolved this using JSON.parse() inside JSNI

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.