我有一个像波纹管这样的模型。
public class ColumnDtoWrapper extends JavaScriptObject{
protected ColumnDtoWrapper() {}
public final native JsArray<ColumnDto> getfields() /*-{
return this.fields;
}-*/;
public final native void gettable() /*-{
return this.table;
}-*/;
public final native JavaScriptObject getHasMany() /*-{
return this.hasmany;
}-*/;
}
我像
一样进行服务器调用RequestBuilder build = new RequestBuilder(RequestBuilder.POST, URL);
try {
Request request = build.sendRequest(null, new RequestCallback(){
@Override
public void onResponseReceived(Request request, Response response) {
if(200== response.getStatusCode()){
}
}
@Override
public void onError(Request request, Throwable exception) {
Window.alert("error : " + exception.getLocalizedMessage());
}
});
} catch (Exception e) {
Window.alert("try err");
}
当我成功响应JSON字符串时。 我想将该字符串转换为ColumnsDtoWrapper。
像ColumnDtoWrapper col = new ColumnDtoWrapper(responce.getText());
但它不起作用是否有任何好的方法将字符串转换为JavaScriptObject?
答案 0 :(得分:2)
ColumnDtoWrapper col = JsonUtils.safeEval(response.getText());