You need to decode Message.class.

So instead of:
/AutoBean<Person> bean = AutoBeanCodex.decode(factory, Person.class, json);

Do this: /
/ AutoBean<Message> bean = AutoBeanCodex.decode(factory, Message.class,json );/

Take a look here: https://gist.github.com/dozed/912ebc73dbeb43f3a539

Regards,
Stefan

On 02.04.2013 16:24, [email protected] wrote:
Thank you for your answers.
- Thomas:
Yes, it works. But the problem is that I don't know John. It can be anything else. For example the JSON can be: /{"records": [{"names": {"Cedric": ["50", "H", "US"], "Jean": ["50", "H", "US"]}, "style": "TR"}]} /or {"records": /[{"names": {"Blabla": ["50", "H", "US"]}, "style": "TR"}]}. /To get the lists, I have to get the names first. And I don't know how to do.
- Stefan:
I try to do that but I get *null *even for /bean.as().getStyle()./ I don't understand how this method can get the properties..
/interface Message {
   List<Person> getRecords();
 }/
/interface Person {
  Map<String, List<String>> getNames();
   String getStyle();
 }/
/ // Declare the factory type
 interface MyFactory extends AutoBeanFactory {
   AutoBean<Message> message();
   AutoBean<Person> person();
 }/

/public class HelloWorld implements IsWidget,EntryPoint {


  public Widget asWidget() {
   String url="data.json";
   RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
     try {
Request response = builder.sendRequest(null, new RequestCallback() {
         public void onError(Request request, Throwable exception) {
           // Code omitted for clarity
         }/
/ public void onResponseReceived(Request request, Response response) {
           MyFactory factory = GWT.create(MyFactory.class);

AutoBean<Person> bean = AutoBeanCodex.decode(factory, Person.class, response.getText());

          System.out.println("oui "+ bean.as().getNames());
/
/         }/
/       });
     } catch (RequestException e) {
     }
  return null;

   }/

/@Override
public void onModuleLoad() {

 asWidget();
}

}
/

Le mardi 2 avril 2013 04:00:02 UTC-4, Thomas Broyer a écrit :



    On Monday, April 1, 2013 5:51:26 PM UTC+2,
    [email protected] wrote:

        Thank you for your answer. If I do that:
        /public final native JsArray<json> getTest()
             /*-{
                 return this.records[0].names.John;
             }-*/;/
        /
        /I get *50,H,US, *so it's OK for that. But I'm not supposed to
        know "John" or "Jack", so how can I get them?


    Does /this.records[0].names["John"]/ works? If so, there shouldn't
    be any problem replacing the "John" with a method argument.

--
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 [email protected].
To post to this group, send email to [email protected].
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.



--
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 [email protected].
To post to this group, send email to [email protected].
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.


Reply via email to