我的 JsonArray 看起来像这样:
JSONArray itemsJsonArray = new JSONArray();
JSONObject jsobj = new JSONObject();
jsobj.put("a", new JSONString("hi"));
jsobj.put("b", new JSONString("hgjjh"));
jsobj.put("c", new JSONNumber(149077));
itemsJsonArray.set(0, jsobj);
我需要与 JsArray 等效的数据(包:com.google.gwt.core.client),因为我需要使用的 API 只接受 JsArray。
我需要转换为特定的 JsArray 而不是任何 JsonObject,并且不能承担序列化数据的开销。
与上述结构为 key : value 的数据等效的 JsArray 的结构是什么?
最佳答案
根据您的评论编辑的答案:
查看 package 的 Javadoc 之后你提到过,也许试试这个:
JsArrayMixed jsArray = new JsArrayMixed();
for (int i = 0; i < jsonArray.length(); ++i){
jsArray.push(jsonArray.get(i));
}
请记住,您需要将 jsonArray
中的对象解析为 JavaScriptObject
。
关于javascript - 如何将 JSONArray 转换为 JsArray?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44409193/