Package com.alibaba.fastjson.serializer

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


    }
   
    public void test_6 () throws Exception {
        SerializeWriter out = new SerializeWriter(1);
        out.writeString("中文");
        Assert.assertEquals("\"中文\"", new String(out.toBytes("UTF-16"), "UTF-16"));
    }
   
    public void test_null () throws Exception {
        SerializeWriter out = new SerializeWriter(1);
        out.writeString(null);
View Full Code Here


    }
   
    public void test_null () throws Exception {
        SerializeWriter out = new SerializeWriter(1);
        out.writeString(null);
        Assert.assertEquals("null", new String(out.toBytes("UTF-16"), "UTF-16"));
    }
}
View Full Code Here

            {
                String text = "abc";
                String charset = "UTF-8";
                SerializeWriter writer = new SerializeWriter();
                writer.append(text);
                byte[] bytes = writer.toBytes(charset);
                Assert.assertArrayEquals(text.getBytes(charset), bytes);
            }
           
            {
                String text = "efg";
View Full Code Here

            {
                String text = "efg";
                String charset = "UTF-8";
                SerializeWriter writer = new SerializeWriter();
                writer.append(text);
                byte[] bytes = writer.toBytes(charset);
                Assert.assertArrayEquals(text.getBytes(charset), bytes);
            }
        }
    }
}
View Full Code Here

                serializer.config(feature, true);
            }

            serializer.write(object);

            return out.toBytes("UTF-8");
        } finally {
            out.close();
        }
    }
View Full Code Here

                serializer.config(feature, true);
            }

            serializer.write(object);

            return out.toBytes("UTF-8");
        } finally {
            out.close();
        }
    }
View Full Code Here

        serializer.config(feature, true);
      }

      serializer.write(object);

      return out.toBytes("UTF-8");
    } finally {
      out.close();
    }
  }
View Full Code Here

        serializer.config(feature, true);
      }

      serializer.write(object);

      return out.toBytes("UTF-8");
    } finally {
      out.close();
    }
  }
View Full Code Here

    }
   
    public void test_2 () throws Exception {
        SerializeWriter out = new SerializeWriter(SerializerFeature.UseSingleQuotes);
        out.writeString("abc");
        Assert.assertEquals("'abc'", new String(out.toBytes(null), "ISO-8859-1"));
    }
   
    public void test_3 () throws Exception {
        SerializeWriter out = new SerializeWriter(SerializerFeature.UseSingleQuotes);
        out.writeString("abc");
View Full Code Here

    }
   
    public void test_3 () throws Exception {
        SerializeWriter out = new SerializeWriter(SerializerFeature.UseSingleQuotes);
        out.writeString("abc");
        Assert.assertEquals("'abc'", new String(out.toBytes("UTF-16"), "UTF-16"));
    }
   
    public void test_5 () throws Exception {
        SerializeWriter out = new SerializeWriter(1);
        out.write((String) null);
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.