bonjour, je n'arrives pas à parser mon flux json en objet
mon json :
mon produit
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 [{ "products_id": "223", "products_name": "tuto", "products_description": "", "products_model": "tutu", "products_image": "http://...200.jpg", "products_price": "999", "products_devise": "", "products_remise": 0, "products_price_remise": "999", "attibuts": [{ "id": "2541", "text": "Candy", "description": "toto", "prefix" : "+", "price" : "8" }]
et mon attribut :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package.....client.entity; import com.google.gwt.core.client.JavaScriptObject; import com.google.gwt.core.client.JsArray; public class Produit extends JavaScriptObject { protected Produit() {} // JSNI methods to get stock data. public final native String getSymbol() /*-{ return this.symbol; }-*/; public final native String getProducts_id() /*-{ return this.products_id; }-*/; public final native String getProducts_name() /*-{ return this.products_name; }-*/; public final native String getProducts_description() /*-{ return this.products_description; }-*/; public final native String getProducts_model() /*-{ return this.products_model; }-*/; public final native String getProducts_image() /*-{ return this.products_image; }-*/; public final native String getProducts_price() /*-{ return this.products_price; }-*/; public final native String getProducts_devise() /*-{ return this.products_devise; }-*/; public final native String getproducts_price_remise() /*-{ return this.products_price_remise; }-*/; public final native int getproducts_remise() /*-{ return this.products_remise; }-*/; public final native JsArray<Attribut> getAttributs() /*-{ return this.attibuts; }-*/; }
Dans l'Entry point j'utilise ;
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 import com.google.gwt.core.client.JavaScriptObject; public class Attribut extends JavaScriptObject { protected Attribut() {} // JSNI methods to get stock data. public final native String getId() /*-{ return this.id; }-*/; public final native String getText() /*-{ return this.text; }-*/; public final native String getDescription() /*-{ return this.description; }-*/; public final native String getPrefix() /*-{ return this.prefix; }-*/; public final native String getPrice() /*-{ return this.price; }-*/; }
j'y arrive tres bien, tant que je ne mets pas la partie attribut. Apres ca plante
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 private final native JsArray<Produit> asArrayOfStockData(String json) /*-{ return eval(json); }-*/;
Je dois mal mapper le deuxieme objet ?
Avez vous une idée ?
Merci
Partager