-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
How can I save json object in file in order? #1717
Copy link
Copy link
Closed
Labels
kind: questionrelease item: ✨ new featuresolution: proposed fixa fix for the issue has been proposed and waits for confirmationa fix for the issue has been proposed and waits for confirmation
Milestone
Description
Activity
Metadata
Metadata
Assignees
Labels
kind: questionrelease item: ✨ new featuresolution: proposed fixa fix for the issue has been proposed and waits for confirmationa fix for the issue has been proposed and waits for confirmation
I create a json object and save it in file:
json root = { { "information", { {"model", 1}, {"dof", 6}, {"aux dof", 0} } }, { "cartisian limit", { { "translation", { {"velocity", 1}, {"acceleration", 1}, {"deceleration", 1}, {"jerk", 1} } }, { "rotation", { {"velocity", 1}, {"acceleration", 1}, {"deceleration", 1}, {"jerk", 1} } } } } }; std::ofstream ob("robot_params.json"); ob << std::setw(4) << root << std::endl;And the file robot_params.json looks like this:
{ "cartisian limit": { "rotation": { "acceleration": 1, "deceleration": 1, "jerk": 1, "velocity": 1 }, "translation": { "acceleration": 1, "deceleration": 1, "jerk": 1, "velocity": 1 } }, "information": { "aux dof": 0, "dof": 6, "model": 1 } }But what I need is saving the json object in order like this:
{ "information": { "model": 1, "dof": 6, "aux dof": 0 }, "cartisian limit": { "translation": { "velocity": 1, "acceleration": 1, "deceleration": 1, "jerk": 1 }, "rotation": { "velocity": 1, "acceleration": 1, "deceleration": 1, "jerk": 1 } } }Please let me know is it feasible to do so?