Search in sources :

Example 66 with SerializeWriter

use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.

the class StringSerializerTest method test_11_d.

public void test_11_d() throws Exception {
    SerializeWriter out = new SerializeWriter();
    out.writeString("123\na\nb\nc\nd\"'e", ':');
    Assert.assertEquals("\"123\\na\\nb\\nc\\nd\\\"'e\":", out.toString());
}
Also used : SerializeWriter(com.alibaba.fastjson.serializer.SerializeWriter)

Example 67 with SerializeWriter

use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.

the class SerializeWriterTest method test_error_5.

public void test_error_5() throws Exception {
    Exception error = null;
    try {
        SerializeWriter out = new SerializeWriter(16);
        out.write(new char[0], 0, 1);
    } catch (IndexOutOfBoundsException ex) {
        error = ex;
    }
    Assert.assertNotNull(error);
}
Also used : SerializeWriter(com.alibaba.fastjson.serializer.SerializeWriter)

Example 68 with SerializeWriter

use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.

the class SerializeWriterTest method test_13.

public void test_13() throws Exception {
    SerializeWriter out = new SerializeWriter(1);
    out.writeInt(Integer.MIN_VALUE);
    Assert.assertEquals(Integer.toString(Integer.MIN_VALUE), out.toString());
}
Also used : SerializeWriter(com.alibaba.fastjson.serializer.SerializeWriter)

Example 69 with SerializeWriter

use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.

the class SerializeWriterTest method test_error_3.

public void test_error_3() throws Exception {
    Exception error = null;
    try {
        SerializeWriter out = new SerializeWriter(16);
        out.write(new char[0], 2, 0);
    } catch (IndexOutOfBoundsException ex) {
        error = ex;
    }
    Assert.assertNotNull(error);
}
Also used : SerializeWriter(com.alibaba.fastjson.serializer.SerializeWriter)

Example 70 with SerializeWriter

use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.

the class SerializeWriterTest method test_13_long.

public void test_13_long() throws Exception {
    SerializeWriter out = new SerializeWriter(1);
    out.writeLong(Long.MIN_VALUE);
    Assert.assertEquals(Long.toString(Long.MIN_VALUE), out.toString());
}
Also used : SerializeWriter(com.alibaba.fastjson.serializer.SerializeWriter)

Aggregations

SerializeWriter (com.alibaba.fastjson.serializer.SerializeWriter)345 JSONSerializer (com.alibaba.fastjson.serializer.JSONSerializer)206 PropertyFilter (com.alibaba.fastjson.serializer.PropertyFilter)54 HashMap (java.util.HashMap)47 StringWriter (java.io.StringWriter)38 NameFilter (com.alibaba.fastjson.serializer.NameFilter)36 ValueFilter (com.alibaba.fastjson.serializer.ValueFilter)19 ArrayList (java.util.ArrayList)12 ListSerializer (com.alibaba.fastjson.serializer.ListSerializer)11 MapSerializer (com.alibaba.fastjson.serializer.MapSerializer)10 JavaBeanSerializer (com.alibaba.fastjson.serializer.JavaBeanSerializer)8 Date (java.util.Date)8 Map (java.util.Map)8 CollectionCodec (com.alibaba.fastjson.serializer.CollectionCodec)6 SerializeConfig (com.alibaba.fastjson.serializer.SerializeConfig)6 LinkedHashMap (java.util.LinkedHashMap)6 JSONException (com.alibaba.fastjson.JSONException)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 A (com.alibaba.json.bvt.serializer.filters.PropertyFilterTest.A)4 JSONObject (com.alibaba.fastjson.JSONObject)3