Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature.InitStringFieldAsEmpty 参数问题 #2387

Closed
tungSing opened this issue Apr 19, 2019 · 1 comment
Closed

Feature.InitStringFieldAsEmpty 参数问题 #2387

tungSing opened this issue Apr 19, 2019 · 1 comment
Labels
Milestone

Comments

@tungSing
Copy link

把json字符串转换为实体对象时:用了Feature.InitStringFieldAsEmpty参数,在1.2.29版本之前可以给对象正确赋值,之后的版本就无法赋值了。
对象实体:

public class TestEntity {
    private String id;
    private String ddd;
    private String name;
    //get set
}

测试main方法

public static void main(String[] args) {
    String jsonStr = "{id:\"ss\",ddd:\"sdfsd\",name:\"hh\"}";
    TestEntity news = JSON.parseObject(jsonStr, TestEntity.class, Feature.InitStringFieldAsEmpty);
    System.out.println(news.toString());
}
@wenshao wenshao added this to the 1.2.58 milestone Apr 22, 2019
@wenshao wenshao added the bug label Apr 22, 2019
@wuwen5
Copy link
Contributor

wuwen5 commented Jul 19, 2019

正确的json格式key必须带双引号

String jsonStr = "{\"id\":\"ss\",\"ddd\":\"sdfsd\",\"name\":\"hh\"}";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants