use of com.alibaba.fastjson.JSONArray in project weex-example by KalicyZhou.
the class WXModuleManagerTest method testCallModuleMethod3.
@Test
public void testCallModuleMethod3() throws Exception {
JSONArray args = new JSONArray();
args.add("testarg");
args.add(null);
WXModuleManager.callModuleMethod(instance.getInstanceId(), "test1", "testCallbackMethod", args);
}
use of com.alibaba.fastjson.JSONArray in project weex-example by KalicyZhou.
the class WXDomModuleTest method testCallDomMethod.
@Test
public void testCallDomMethod() throws Exception {
module.callDomMethod(null);
JSONObject obj = new JSONObject();
for (String m : METHODS) {
obj.put(WXBridgeManager.METHOD, m);
module.callDomMethod(obj);
}
obj = new JSONObject();
for (Object[] args : ARGS_CASES) {
JSONArray ary = new JSONArray();
if (args == null) {
ary = null;
} else {
for (Object arg : args) {
ary.add(arg);
}
}
obj.put(WXBridgeManager.ARGS, ary);
for (String m : METHODS) {
obj.put(WXBridgeManager.METHOD, m);
module.callDomMethod(obj);
}
}
}
use of com.alibaba.fastjson.JSONArray in project weex-example by KalicyZhou.
the class WXDomObjectTest method testClone.
@Test
public void testClone() throws Exception {
JSONObject.parseObject("{\"ref\":\"100\",\"type\":\"div\",\"attr\":{},\"style\":{\"backgroundColor\":\"rgb(40,96,144)\",\"fontSize\":40,\"color\":\"#ffffff\",\"paddingRight\":30,\"paddingLeft\":30,\"paddingBottom\":20,\"paddingTop\":20}}");
JSONObject obj = new JSONObject();
obj.put("ref", "101");
obj.put("type", "test");
JSONArray event = new JSONArray();
event.add("click");
obj.put("event", event);
dom.parseFromJson(obj);
WXDomObject clone = dom.clone();
assertEquals(clone.getRef(), "101");
assertEquals(clone.getType(), "test");
}
use of com.alibaba.fastjson.JSONArray in project api-manager by cehome-com.
the class AmActionServiceImpl method buildMockData.
private JSONObject buildMockData(List<JSONObject> columnList) {
JSONObject mockObject = new JSONObject();
for (JSONObject column : columnList) {
int columnType = column.getIntValue("type");
if (CommonMeta.JavaType.NUMBER.getCode() == columnType || CommonMeta.JavaType.STRING.getCode() == columnType || CommonMeta.JavaType.BOOLEAN.getCode() == columnType || CommonMeta.JavaType.ARRAY_NUMBER.getCode() == columnType || CommonMeta.JavaType.ARRAY_STRING.getCode() == columnType || CommonMeta.JavaType.ARRAY_BOOLEAN.getCode() == columnType) {
String name = column.getString("name");
String rule = StringUtils.isEmpty(column.getString("rule")) ? "" : "|" + column.getString("rule");
Object value = column.get("value");
mockObject.put(name + rule, value);
} else if (CommonMeta.JavaType.OBJECT.getCode() == columnType) {
String name = column.getString("name");
List<JSONObject> children = column.getJSONArray("child").toJavaList(JSONObject.class);
JSONObject columnObject = buildMockData(children);
mockObject.put(name, columnObject);
} else if (CommonMeta.JavaType.ARRAY_OBJECT.getCode() == columnType) {
JSONArray objectArray = new JSONArray();
String name = column.getString("name");
List<JSONObject> children = column.getJSONArray("child").toJavaList(JSONObject.class);
for (JSONObject child : children) {
List<JSONObject> innerChildren = child.getJSONArray("child").toJavaList(JSONObject.class);
JSONObject innerColumnObject = buildMockData(innerChildren);
objectArray.add(innerColumnObject);
}
mockObject.put(name, objectArray);
}
}
return mockObject;
}
use of com.alibaba.fastjson.JSONArray in project CorePage by lizhangqu.
the class CorePageManager method readConfig.
/**
* 从配置文件中读取page
*/
public void readConfig(String content) {
Log.d(TAG, "readConfig from json");
JSONArray jsonArray = JSON.parseArray(content);
Iterator<Object> iterator = jsonArray.iterator();
JSONObject jsonPage = null;
String pageName = null;
String pageClazz = null;
String pageParams = null;
while (iterator.hasNext()) {
jsonPage = (JSONObject) iterator.next();
pageName = jsonPage.getString("name");
pageClazz = jsonPage.getString("class");
pageParams = jsonPage.getString("params");
if (TextUtils.isEmpty(pageName) || TextUtils.isEmpty(pageClazz)) {
Log.d(TAG, "page Name is null or pageClass is null");
return;
}
mPageMap.put(pageName, new CorePage(pageName, pageClazz, pageParams));
Log.d(TAG, "put a page:" + pageName);
}
Log.d(TAG, "finished read pages,page size:" + mPageMap.size());
}
Aggregations