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

add json string in previous string?? #1025

Closed
Mamlesh opened this issue Mar 27, 2018 · 4 comments
Closed

add json string in previous string?? #1025

Mamlesh opened this issue Mar 27, 2018 · 4 comments
Labels
kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation

Comments

@Mamlesh
Copy link

Mamlesh commented Mar 27, 2018

1st string..

{ { "Layer", },
{ "Data",{
{ { "Type", },{ "Count", },
{ "Point",
{

}
}
}
} },
};

2nd string..

{ "Point1",
{
{ "X", },
{ "Y", },
{ "Z", }
} },

how to add 2nd string into "Point" section of 1st string???

@nlohmann
Copy link
Owner

The example is not JSON. Could you provide a concrete example with proper JSON or C++ code?

@nlohmann nlohmann added the state: needs more info the author of the issue needs to provide more details label Mar 27, 2018
@Mamlesh
Copy link
Author

Mamlesh commented Mar 27, 2018

1st string...

{
"HATCH": [
{
"Data": [
{
"Count": 7,
"Point": null,
"Type": "Hatch"
}
],
"Layer": "HATCH_T"
}
]
}

2nd string...

{
"Point1": {
"X": 4148.616151219332,
"Y": 2449.979364191569,
"Z": 0
}
}

add 2nd string in 1st "Point" key..

@nlohmann
Copy link
Owner

nlohmann commented Mar 27, 2018

Similar to #1012, use operator[] to navigate in objects and arrays:

// assuming s1 is the JSON value for the first string and s2 the one for the second string
s1["HATCH"][0]["Data"][0]["Point"].push_back(s2);

@nlohmann nlohmann added solution: proposed fix a fix for the issue has been proposed and waits for confirmation and removed state: needs more info the author of the issue needs to provide more details labels Mar 27, 2018
@nlohmann
Copy link
Owner

@Mamlesh Did that work?

@nlohmann nlohmann closed this as completed Apr 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation
Projects
None yet
Development

No branches or pull requests

2 participants