gwtでjsonを構文解析しようとしていますが、動作しません。私は初心者なので、これは明らかな愚かな間違いかもしれません。アレイは正しく収集されません。オーバーレイシステムでgwt jsonシリアライゼーションを動作させることはできません - 配列は常に空です。
これは私がデバッグだWICH上のコードの一部です:
String json = "{\"lokacije\":[{\"sifraLokacije\":1,\"nazivLokacije\":\"Policijska stanica\",\"brojDokumenata\":70}],\"status\":1}";
LocationsResponse locationsResponse = createLocationsResponse("("+json+")");
// this is ok, status is 1
int status = locationsResponse.getStatus();
// length of this array is 0 and you can see from json that it has one element (the same if it has more)
int brojLokacija = locationsResponse.getLokacije().length();
...
private final native LocationsResponse createLocationsResponse(String json) /*-{
return eval(json);
}-*/;
LocationsResponseクラス:
public class LocationsResponse extends JavaScriptObject {
protected LocationsResponse() {}
public final native int getStatus() /*-{ return this.status; }-*/;
public final native JsArray<JSOLokacija> getLokacije() /*-{ this.lokacije; }-*/;
}
JSOLokacijaクラス:
public class JSOLokacija extends JavaScriptObject {
protected JSOLokacija() {} ;
public final native int getSifraLokacije() /*-{ this.sifraLokacije; }-*/;
public final native String getNazivLokacije() /*-{ this.nazivLokacije; }-*/;
public final native int getBrojDokumenata() /*-{ this.brojDokumenata; }-*/;
}
JSNIメソッドでリターンがありませんでした。ただ私を無視する。私はちょうどTwighlightを見たように感じ、私の人生の3時間を捨てて... –