use of com.alibaba.fastjson.JSONArray in project fastjson by alibaba.
the class Bug_for_jiangwei2 method test_for_jiangwei.
public void test_for_jiangwei() throws Exception {
// String str = "[2,'韩国篮球联赛','仁川大象(男篮)','首尔SK骑士 男篮',['大/小',3],'总进球 : 138.5 @ 0-0','','大','0.66','',1,25,200,1,0,0,'True','False',0,'','','',0,0,19819905,1,'h',145528,0]";
// JSONArray array = JSON.parseArray(str);
String str = "[]";
str = "[]";
JSONArray array = JSON.parseArray(str);
}
use of com.alibaba.fastjson.JSONArray in project fastjson by alibaba.
the class Bug_for_liuying method test_for_bug.
public void test_for_bug() throws Exception {
String aa = "[{\"dictFont\":\"\",\"dictId\":\"wap\",\"dictName\":\"无线&手淘\"},{\"dictFont\":\"\",\"dictId\":\"etao\",\"dictName\":\"搜索\"}]";
JSONObject jsonResult = new JSONObject();
JSONArray jsonArray = JSONArray.parseArray(aa);
jsonResult.put("aaa", jsonArray);
System.out.println(jsonResult);
}
use of com.alibaba.fastjson.JSONArray in project fastjson by alibaba.
the class Bug_for_issue_430 method test_for_issue.
public void test_for_issue() throws Exception {
String text = "[{\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}, {\"@type\": \"com.alibaba.json.bvt.bug.Bug_for_issue_430$FooModel\", \"fooCollection\": null}]";
JSONArray array = JSON.parseArray(text);
Assert.assertEquals(FooModel.class, array.get(0).getClass());
Assert.assertEquals(FooModel.class, array.get(1).getClass());
Assert.assertNull(((FooModel) array.get(0)).fooCollection);
Assert.assertNull(((FooModel) array.get(1)).fooCollection);
}
use of com.alibaba.fastjson.JSONArray in project fastjson by alibaba.
the class StackTraceElementTest method test_stackTrace.
public void test_stackTrace() throws Exception {
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
String text = JSON.toJSONString(stackTrace, SerializerFeature.WriteClassName);
JSONArray array = (JSONArray) JSON.parse(text);
for (int i = 0; i < array.size(); ++i) {
StackTraceElement element = (StackTraceElement) array.get(i);
Assert.assertEquals(stackTrace[i].getFileName(), element.getFileName());
Assert.assertEquals(stackTrace[i].getLineNumber(), element.getLineNumber());
Assert.assertEquals(stackTrace[i].getClassName(), element.getClassName());
Assert.assertEquals(stackTrace[i].getMethodName(), element.getMethodName());
}
}
use of com.alibaba.fastjson.JSONArray in project fastjson by alibaba.
the class Issue74 method test_for_issue.
public void test_for_issue() throws Exception {
InputStream is = Issue72.class.getClassLoader().getResourceAsStream("issue74.json");
String text = org.apache.commons.io.IOUtils.toString(is);
is.close();
JSONArray json = (JSONArray) JSON.parse(text);
Assert.assertNotNull(json.getJSONObject(0).getJSONObject("dataType").getJSONObject("categoryType").getJSONArray("dataTypes").get(0));
Assert.assertSame(json.getJSONObject(0).getJSONObject("dataType"), json.getJSONObject(0).getJSONObject("dataType").getJSONObject("categoryType").getJSONArray("dataTypes").get(0));
}
Aggregations