過去数日間、私はGWTにJSONValueまたはPHPを使用してサーバーから返されるXML文字列を解釈しようとしていました。GWTを使用したXMLまたはJSONの解析の挫折
私は仕事に何かを得ることができないので、かなり不満です。 XMLの場合、PHPからGWTに渡される文字列が正しいXML文字列であることを確認しました。しかし、私はXMLを解析しようとすると、私はヌルエラーの束を取得します。 JSONで
、私はPHPから次を得る:
Value: {"item":[{"ID":null, "Primary":null, "Secondary":null, "Date":null, "Region":null},{"ID":null, "Primary":null, "Secondary":null, "Date":null, "Region":null},{"ID":null, "Primary":null, "Secondary":null, "Date":null, "Region":null}]}
私は値がNULLである理由はわかりませんが、これはGWTはJSONのためにどのように見えるかです:
public void onChange(Widget sender) {
lb.setText("Date selected: " + calendar.getDate());
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String current = df.format(calendar.getDate());
RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, URL.encode("http://www.kbehr.com/calendar/view_duty.php"));
try {
builder.sendRequest(current, new RequestCallback(){
public void onError(Request request, Throwable exception) {
requestFailed(exception);
}
public void onResponseReceived(Request request, Response response) {
String responseText = response.getText();
try {
JSONValue jsonValue = JSONParser.parse(responseText);
processJSON(jsonValue);
} catch (Exception e) {
Window.alert("Error: " + e);
}
}});
}catch (RequestException ex) {
requestFailed(ex);
}
}});
fp.add(calendar);
fp.add(lb);
}
public void processJSON(JSONValue messageXml) {
vp.clear();
vp.add(new Label("Value: " + messageXml));
RootPanel.get("slot2").add(vp);
}
誰かが私がJSONで間違っていることを知っていますか?私はPHPでjson_encode($ array)をやっていますが、GWTでどのように分解するのか分かりません。
残念ながら、多くの例が
おかげで...どちらか、オンラインに存在しません!