有一个特殊的类型,不希望按照 bean 方式json 化,能不能用自己的方法替换。
认证0级讲师
Solved it myself:
ObjectSerializer recordFilter = new ObjectSerializer() { @Override public void write(JSONSerializer jsonSerializer, Object o, Object o1, Type type) throws IOException { SerializeWriter out = jsonSerializer.getWriter(); Record record = (Record) o; if( record != null){ out.write(record.toJson()); }else{ out.writeNull(); } } }; public LocalConductor() { SerializeConfig.getGlobalInstance() .put(Record.class, recordFilter); }
Interface may change
Use the put method of the SerializeConfig class to modify the parsing of the specified type.
I don’t understand very well, you can post an example. If you don’t use beans, you can use fastjson’s get method to return the result
JSONSerializer
Solved it myself:
Interface may change
Use the put method of the SerializeConfig class to modify the parsing of the specified type.
I don’t understand very well, you can post an example. If you don’t use beans, you can use fastjson’s get method to return the result
JSONSerializer