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

JSONMap does not add attributes to child nodes #1287

Open
kirillmsq opened this issue Apr 27, 2023 · 0 comments
Open

JSONMap does not add attributes to child nodes #1287

kirillmsq opened this issue Apr 27, 2023 · 0 comments
Assignees

Comments

@kirillmsq
Copy link

kirillmsq commented Apr 27, 2023

JSONMap does not add attributes to child nodes, only to the root.

private static final String JSON = """
        {
            "child1" : {
                "attr1": "something"
            }
        }
        """;

@Test
public void test() {
    var json = JSONHelper.toMap(JSON);
    System.out.println(json);
    json.put("child2", "anything");
    System.out.println(json);
    json.getMap("child1").put("attr2", "new");
    System.out.println(json);
}

Actual output:
{"child1":{"attr1":"something"}}
{"child2":"anything","child1":{"attr1":"something"}}
{"child2":"anything","child1":{"attr1":"something"}}

@ipolevoy ipolevoy self-assigned this Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants