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

嵌套对象序列化成JSONObject时,snake_case对内层对象不生效 #2428

@swb0802

Description

@swb0802

`

@NoArgsConstructor
@DaTa
public class DemoBean {

private String myName;
private NestedBean nestedBean;

@AllArgsConstructor
@Data
public static class NestedBean {

    private String myId;
}

public static void main(String[] args) {
    DemoBean demoBean = new DemoBean();
    demoBean.setMyName("test name");
    demoBean.setNestedBean(new NestedBean("test id"));
    SerializeConfig serializeConfig = new SerializeConfig();
    serializeConfig.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;

    System.out.println(JSON.toJSON(demoBean, serializeConfig));

}

}

`

如上代码,输出的结果是:
{"my_name":"test name","nested_bean":{"myId":"test id"}}

其中myId没有转成snake_case,求解

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions