use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class FastjsonSockJsMessageCodec method applyJsonQuoting.
@Override
protected char[] applyJsonQuoting(String content) {
SerializeWriter out = new SerializeWriter();
try {
JSONSerializer serializer = new JSONSerializer(out);
serializer.write(content);
return out.toCharArrayForSpringWebSocket();
} finally {
out.close();
}
}
use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class SwaggerJsonSerializer method write.
public //
void write(//
JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
SerializeWriter out = serializer.getWriter();
Json json = (Json) object;
String value = json.value();
out.write(value);
}
use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class SerializeWriterTest method test_5.
public void test_5() throws Exception {
SerializeWriter writer = new SerializeWriter();
writer.writeLong(-1L);
Assert.assertEquals("-1", writer.toString());
}
use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class SerializeWriterTest method test_1.
public void test_1() throws Exception {
SerializeWriter writer = new SerializeWriter();
writer.writeInt(-1);
Assert.assertEquals("-1", writer.toString());
}
use of com.alibaba.fastjson.serializer.SerializeWriter in project fastjson by alibaba.
the class TypeUtilsTest_castToJavaBean method test_bean_2.
public void test_bean_2() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", 123);
PO vo = TypeUtils.castToJavaBean(map, PO.class);
Assert.assertEquals(123, vo.id);
SerializeWriter out = new SerializeWriter();
try {
SerializeConfig config = new SerializeConfig();
JSONSerializer serializer = new JSONSerializer(out, config);
config.put(PO.class, new JavaBeanSerializer(PO.class, Collections.singletonMap("id", "ID")));
serializer.write(vo);
Assert.assertEquals("{\"ID\":123}", out.toString());
} finally {
out.close();
}
}
Aggregations