Skip to content

Why is an object ordering values by Alphabetical Order?  #660

Description

@gDev95

Hi I am experiencing some weird behaviour I cannot really get behind why it does the following.
Imagine you want to have following json object:

{
	"result_parameters":{
		"Category": 1,
		"Username": "Warrior11",
		"First_Name": "Max",
		"Date_Signed_Up": [1,1,2017]
	}
}

What I did was:

nlohmann::json j;
j["result_parameter"]["Category"] = 1;
j["result_parameter"]["Username"] =  "Warrior11";
j["result_parameter"]["First_Name"] = "Max";
j["result_parameter"]["Date_Signed_Up"] = [1,1,2017];

When I print this ( cout << j.dump<< endl; ) I get following output:

{"result_parameter":{"Category":1,"Date_Signed_Up":[1,1,2017],"First_Name":"Max","Username":"Warrior11"}}

The order is messed up, how come?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

release item: ✨ new featuresolution: duplicatethe issue is a duplicate; refer to the linked issue insteadsolution: invalidthe issue is not related to the librarysolution: proposed fixa fix for the issue has been proposed and waits for confirmationsolution: wontfixthe issue will not be fixed (either it is impossible or deemed out of scope)

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions