Skip to content

Adding a value to an existing json puts it at the beginning instead of the end #2149

Description

@tawmoto

This is a minor problem, but I think it's worth to mention it.

json j2 = {
	{"pi",    3.141},
	{"happy", true}};

j2["abc"] = "123";

std::cout << j2.dump(4) << std::endl;

I get as output

{
    "abc": "123", -->> shouldn't this be at the end? Because I inserted it later in the json
    "happy": true,
    "pi": 3.141
}

How can I insert it at the end, except creating another json and using update function?
Thanks

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions