Skip to content

[BUG]同时设置JSONField与JsonProperty,转字符串和字符串转对象结果不同 #2649

@wbings

Description

@wbings

问题描述

同时设置JSONField与JsonProperty,转字符串和字符串转对象结果不同

环境信息

请填写以下信息:

  • JDK信息:17.0.10
  • 版本信息:Fastjson2 2.0.46

重现步骤

@Data
public static class Node {
    @JSONField(name = "strValue")
    @JsonProperty("str_value")
    private String strValue;
}
public static void main(String[] args) {
    Node node = new Node();
    node.strValue = "hello world";
    String s = JSON.toJSONString(node);
    System.out.println(s);
    Node node1 = JSON.to(Node.class, s);
    System.out.println(node1);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixed

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions