本文整理匯總了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);
}
}