I was the Google Codeing Basics (http://code.google.com/intl/de-DE/webtoolkit/doc/latest/DevGuideCodingBasicsOverlay.html#example-collections) and thought: hey this could be way faster and easier to use than pharsing my JSON object by hand.
So I played with the example and noticed that it worked fine when the JsArray was defined in the HTML file but I couldn’t find a solution to pass a String or Url into the function and it returns me an Overlay Type.
So what I want to do is:
I have this function
private native Customer getFirstCustomer(/*TYPE (preferd String)*/ name) /*-{
return (CASTVALUE TO ???) name;
}-*/;
To which I pass
{"FirstName": "Jimmy"}
as String, and It returns me a Java Object like this:
import com.google.gwt.core.client.JavaScriptObject;
class Customer extends JavaScriptObject {
protected Customer() { }
public final native String getFirstName() /*-{ return this.FirstName; }-*/;
}
Is this possible?
Best regards,
Stefan
Please, do not, by any mean,
eval()things blindly! (security 101)Use GWT’s JsonUtils instead: it’ll use native JSON support in browsers that support it (faster and safer than
eval()) and will validate the JSON beforeeval()ing it in others (that is, IE6, IE7 and old Safaris –pre 4.0.3–, all other browser versions without native JSON are dead by now):