NamingSerTest.java 文件源码

java
阅读 32 收藏 0 点赞 0 评论 0

项目:GitHub 作者:
public void test_kebab() throws Exception {
    SerializeConfig config = new SerializeConfig();
    config.propertyNamingStrategy = PropertyNamingStrategy.KebabCase;

    Model model = new Model();
    model.personId = 1001;
    String text = JSON.toJSONString(model, config);
    Assert.assertEquals("{\"person-id\":1001}", text);

    ParserConfig parserConfig = new ParserConfig();
    parserConfig.propertyNamingStrategy = PropertyNamingStrategy.KebabCase;
    Model model2 = JSON.parseObject(text, Model.class, parserConfig);
    Assert.assertEquals(model.personId, model2.personId);

    Model model3 = JSON.parseObject(text, Model.class);
    Assert.assertEquals(model.personId, model3.personId);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号