Package com.alibaba.fastjson.serializer

Examples of com.alibaba.fastjson.serializer.SerializeWriter.writeByteArray()


        Assert.assertEquals("true", JSON.toJSONString(true));
    }

    public void test_1() throws Exception {
        SerializeWriter out = new SerializeWriter(1);
        out.writeByteArray(new byte[] { 1, 2, 3 });
        Assert.assertEquals("\"AQID\"", out.toString());
    }

    public void test_2() throws Exception {
        SerializeWriter out = new SerializeWriter(100);
View Full Code Here


        Assert.assertEquals("\"AQID\"", out.toString());
    }

    public void test_2() throws Exception {
        SerializeWriter out = new SerializeWriter(100);
        out.writeByteArray(new byte[] { 1, 2, 3 });
        Assert.assertEquals("\"AQID\"", out.toString());
    }
}
View Full Code Here

       
        byte[] bytes = "民主共和君主宪".getBytes("GB2312");
        SerializeWriter writer = new SerializeWriter(out, 10);
        Assert.assertEquals(10, writer.getBufferLength());
       
        writer.writeByteArray(bytes);
        writer.close();
       
        String text = out.toString();
        byte[] result = JSON.parseObject(text, byte[].class);
        Assert.assertEquals("民主共和君主宪", new String(result, "GB2312"));
View Full Code Here

       
        byte[] bytes = "民主".getBytes("GB2312");
        SerializeWriter writer = new SerializeWriter(out, 10);
        Assert.assertEquals(10, writer.getBufferLength());
       
        writer.writeByteArray(bytes);
        writer.close();
       
        String text = out.toString();
        byte[] result = JSON.parseObject(text, byte[].class);
        Assert.assertEquals("民主", new String(result, "GB2312"));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.