use of com.alibaba.fastjson.JSONArray in project wechat-mp-sdk by usc.
the class MenuUtil method buildMenu.
private static Menu buildMenu(String json) {
JSONObject parseObject = JSONObject.parseObject(json);
if (json == null) {
return null;
}
JSONObject menuObject = parseObject.getJSONObject("menu");
if (menuObject == null) {
return null;
}
JSONArray jsonArray = menuObject.getJSONArray("button");
if (jsonArray == null) {
return null;
}
List<MenuInfo> menuInfos = new ArrayList<MenuInfo>();
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject subJsonObject = jsonArray.getJSONObject(i);
String type = subJsonObject.getString("type");
String jsonString = subJsonObject.toString();
if (StringUtils.isNotEmpty(type)) {
menuInfos.add(JSONObject.parseObject(jsonString, SingleMenuInfo.class));
} else {
menuInfos.add(JSONObject.parseObject(jsonString, MultiMenuInfo.class));
}
}
return new Menu(menuInfos);
}
use of com.alibaba.fastjson.JSONArray in project ready-x by CodePlayer.
the class User method parseArray.
@Test
public void parseArray() {
JSONArray jsonArray = JSONUtil.parseArray("['大家好']");
// 大家好
System.out.println(jsonArray.get(0));
}
use of com.alibaba.fastjson.JSONArray in project weex-example by KalicyZhou.
the class WXBridge method callNativeComponent.
/**
* Bridge component Js Method
* @param instanceId Instance ID
* @param componentRef the ref of component
* @param method the name of method
* @param arguments the arguments of the method
* @param options option arguments for extending
*/
@Override
public void callNativeComponent(String instanceId, String componentRef, String method, byte[] arguments, byte[] options) {
JSONArray argArray = JSON.parseArray(new String(arguments));
WXBridgeManager.getInstance().callNativeComponent(instanceId, componentRef, method, argArray, options);
}
use of com.alibaba.fastjson.JSONArray in project weex-example by KalicyZhou.
the class WXDomModule method callDomMethod.
public void callDomMethod(JSONObject task) {
if (task == null) {
return;
}
String method = (String) task.get(WXBridgeManager.METHOD);
JSONArray args = (JSONArray) task.get(WXBridgeManager.ARGS);
callDomMethod(method, args);
}
use of com.alibaba.fastjson.JSONArray in project weex-example by KalicyZhou.
the class WXModuleManagerTest method testCallModuleMethod4.
@Test
public void testCallModuleMethod4() throws Exception {
JSONArray args = new JSONArray();
args.add("testarg");
args.add("testcallbackId");
WXModuleManager.callModuleMethod(instance.getInstanceId(), "test1", "testCallbackMethod", args);
}
Aggregations