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

1.2.59中使用@JSONField注解指定属性序列化使用单引号后不生效 #2678

Closed
Omega-Ariston opened this issue Aug 30, 2019 · 0 comments

Comments

@Omega-Ariston
Copy link
Collaborator

Omega-Ariston commented Aug 30, 2019

在尝试修复 #2355 的时候发现的bug,复现代码:

    public static void main(String[] args) {
        Person person = new Person();
        person.setName("Ariston");
        person.setAge(23);
        String json = JSON.toJSONString(person);
        System.out.println(json);
    }

    static class Person {

        @JSONField(serialzeFeatures = SerializerFeature.UseSingleQuotes)
        private String name;

        private int age;

        public String getName()
        {
            return name;
        }

        public void setName( String name )
        {
            this.name = name;
        }

        public int getAge()
        {
            return age;
        }

        public void setAge( int age )
        {
            this.age = age;
        }
    }

输出字符串为:{"age":23,"name":"Ariston"},而不是{"age":23,'name':'Ariston'}
经测试,注解放在getter方法上也会失效,已定位到问题,稍后提pr修复

@Omega-Ariston Omega-Ariston changed the title 1.2.59中使用@JSONField(serializeFeatures=SerializerFeature.UseSingleQuotes)不生效 1.2.59中使用@JSONField注解指定json使用单引号后不生效 Aug 30, 2019
Omega-Ariston added a commit to Omega-Ariston/fastjson that referenced this issue Aug 30, 2019
Omega-Ariston added a commit to Omega-Ariston/fastjson that referenced this issue Aug 30, 2019
Omega-Ariston added a commit to Omega-Ariston/fastjson that referenced this issue Aug 30, 2019
Omega-Ariston added a commit to Omega-Ariston/fastjson that referenced this issue Aug 30, 2019
@Omega-Ariston Omega-Ariston changed the title 1.2.59中使用@JSONField注解指定json使用单引号后不生效 1.2.59中使用@JSONField注解指定属性序列化使用单引号后不生效 Aug 30, 2019
Omega-Ariston added a commit to Omega-Ariston/fastjson that referenced this issue Aug 30, 2019
wenshao added a commit that referenced this issue Sep 2, 2019
fix issue #2678(使用@JSONField注解指定属性序列化使用单引号后不生效)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant