Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Based_On_Fields_cn

高铁 edited this page Apr 4, 2017 · 1 revision

在1.2.31版本开始,支持based on fields序列化和反序列化,使用方式如下:

SerializeConfig config = new SerializeConfig(true); // singleton
ParserConfig parserConfig = new ParserConfig(true); // singleton

public static class Model {
    private int id;
}

Model model = new Model();
model.id = 123;
assertEquals("{\"id\":123}", JSON.toJSONString(model, config));

Model model2 = JSON.parseObject("{\"id\":123}", Model.class, parserConfig);
assertEquals(model.id, model2.id);
Clone this wiki locally