Friday, March 29, 2013

Complex JSON and overlay types

Hi everybody,
 
I want to read this kind of JSON with GWT:
 

{"records": [{"names": {"John": ["50", "H", "US"], "Jack": ["50", "H", "US"]}, "style": "TR"}]}

I use overlay for that.

If I use that, I get "TR":

 public final native String getStyle()
     /*-{
         return this.records[0].style;
     }-*/;

So, it's work. Now I want to get John and the list 50,H,US. If I use that I get null:

public final native String getNames(String i)
     /*-{
         return this.records[0].names[i];
     }-*/;

For the same thing, I try to do that and I get no result: (json is the of my class which is extended by JavaScriptObject)

       public final native JsArray<json> getArray(String key) /*-{
        return this[key] ? this[key] : new Array();
    }-*/;

and

result.getArray("names").toString()

 

Have you any idea to do what I want?

Thank you in advance !

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment