Package com.alibaba.fastjson

Examples of com.alibaba.fastjson.JSONArray


import com.alibaba.fastjson.JSONObject;

public class CloneTest_0 extends TestCase {
  public void test_0() throws Exception  {
    JSONObject o = new JSONObject();
    o.put("a", new JSONArray());
   
    JSONObject o1 = o.clone();
   
    Assert.assertEquals(o, o1);
    Assert.assertNotSame(o, o1);
View Full Code Here


import com.alibaba.fastjson.JSONArray;

public class JSONArrayTest_hashCode extends TestCase {

    public void test_hashCode() throws Exception {
        Assert.assertEquals(new JSONArray().hashCode(), new JSONArray().hashCode());
    }
View Full Code Here

    }

    public void test_1() throws Exception {
        List list = new ArrayList();

        JSONArray json = (JSONArray) JSON.toJSON(list);

        Assert.assertEquals(list.size(), json.size());
    }
View Full Code Here

        JSONObject json = JSON.parseObject("{\"val\":12.3}");
        Assert.assertEquals(12.3D, json.getDoubleValue("val"));
    }
   
    public void test_JSONArray_double() throws Exception {
        JSONArray json = JSON.parseArray("[12.3]");
        Assert.assertEquals(12.3D, json.getDoubleValue(0));
    }
View Full Code Here

        String jsonString = JSONObject.toJSONString(entry);
        String arrayString = JSONObject.toJSONString(list);
        System.out.println(jsonString);
        System.out.println(arrayString);
        list = JSONArray.parseArray(arrayString, OuterEntry.class);
        JSONArray array = JSONArray.parseArray(arrayString);// 这一步出错
    }
View Full Code Here

public class StackTraceElementTest extends TestCase {
    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());
        }
View Full Code Here

        map.put("a", 1);
        Assert.assertEquals(obj.size(), map.size());
        Assert.assertEquals(obj.get("a"), map.get("a"));

        map.put("b", new int[] { 1 });
        JSONArray array = obj.getJSONArray("b");
        Assert.assertEquals(array.size(), 1);

        map.put("c", new JSONArray());
        JSONArray array2 = obj.getJSONArray("b");
        Assert.assertEquals(array2.size(), 1);

        Assert.assertEquals(obj.getByteValue("d"), 0);
        Assert.assertEquals(obj.getShortValue("d"), 0);
        Assert.assertEquals(obj.getFloatValue("d"), 0F);
        Assert.assertEquals(obj.getDoubleValue("d"), 0D);
View Full Code Here

  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);
  }
View Full Code Here

            Assert.assertSame(result[0].getMaster(), result[0].getPs()[0]);
            Assert.assertSame(result[1].getMaster(), result[1].getPs()[0]);
            Assert.assertSame(result[2].getMaster(), result[2].getPs()[0]);
        }
        {
            JSONArray array = JSON.parseArray(sfs);
            for (int i = 0; i < array.size(); ++i) {
                JSONObject jsonObj = array.getJSONObject(i);
                Assert.assertSame(jsonObj.get("master"), jsonObj.getJSONArray("ps").get(0));
            }
        }
    }
View Full Code Here

            text = JSON.toJSONString(list);
           
            System.out.println(text);
        }

        JSONArray array = JSON.parseArray(text);

        Body body = array.getObject(1, Body.class);

        Assert.assertEquals("张三", body.getName());
        Assert.assertEquals(1, body.getItems().size());
    }
View Full Code Here

TOP

Related Classes of com.alibaba.fastjson.JSONArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.