本文整理汇总了Java中com.alibaba.fastjson.serializer.JSONSerializer.close方法的典型用法代码示例。如果您正苦于以下问题:Java JSONSerializer.close方法的具体用法?Java JSONSerializer.close怎么用?Java JSONSerializer.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.fastjson.serializer.JSONSerializer
的用法示例。
在下文中一共展示了JSONSerializer.close方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_0
import com.alibaba.fastjson.serializer.JSONSerializer; //导入方法依赖的package包/类
public void test_0() throws Exception {
JSONSerializer serializer = new JSONSerializer();
serializer.setDateFormat("yyyy");
Assert.assertEquals("yyyy", ((SimpleDateFormat) serializer.getDateFormat()).toPattern());
Assert.assertEquals("yyyy", serializer.getDateFormatPattern());
serializer.setDateFormat("yyyy-MM");
Assert.assertEquals("yyyy-MM", ((SimpleDateFormat) serializer.getDateFormat()).toPattern());
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
format.setTimeZone(JSON.defaultTimeZone);
serializer.setDateFormat(format);
Assert.assertEquals("yyyy-MM-dd", serializer.getDateFormatPattern());
serializer.close();
}
示例2: test_0
import com.alibaba.fastjson.serializer.JSONSerializer; //导入方法依赖的package包/类
public void test_0() throws Exception {
JSONSerializer serializer = new JSONSerializer();
serializer.getNameFilters().add(new PascalNameFilter());
Map<String, Object> vo = new LinkedHashMap<String, Object>();
vo.put("", 123);
vo.put(null, "wenshao");
serializer.write(vo);
Assert.assertEquals("{\"\":123,null:\"wenshao\"}", serializer.toString());
serializer.close();
}
示例3: test_
import com.alibaba.fastjson.serializer.JSONSerializer; //导入方法依赖的package包/类
public void test_() throws Exception {
JSONSerializer ser = new JSONSerializer(new SerializeConfig());
ser.setDateFormat(new ISO8601DateFormat());
Assert.assertEquals(null, ser.getDateFormatPattern());
ser.close();
}
示例4: test_0
import com.alibaba.fastjson.serializer.JSONSerializer; //导入方法依赖的package包/类
public void test_0() throws Exception {
JSONSerializer serializer = new JSONSerializer();
serializer.getNameFilters().add(new PascalNameFilter());
VO vo = new VO();
vo.setId(123);
vo.setName("wenshao");
serializer.write(vo);
Assert.assertEquals("{\"Id\":123,\"Name\":\"wenshao\"}", serializer.toString());
serializer.close();
}
示例5: ser
import com.alibaba.fastjson.serializer.JSONSerializer; //导入方法依赖的package包/类
@Benchmark
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public void ser(Blackhole bh) throws IOException {
for (int i = 0; i < 1000; i++) {
byteArrayOutputStream.reset();
SerializeWriter writer = new SerializeWriter();
JSONSerializer serializer = new JSONSerializer(writer, serializeConfig);
serializer.write(testObject);
writer.writeToEx(byteArrayOutputStream, IOUtils.UTF8);
serializer.close();
bh.consume(byteArrayOutputStream);
}
}