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

how to add two json string in single object?? #1012

Closed
Mamlesh opened this issue Mar 13, 2018 · 2 comments
Closed

how to add two json string in single object?? #1012

Mamlesh opened this issue Mar 13, 2018 · 2 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 13, 2018

like..

{
	"WALL": [
		{
			"Data": {
				"Count": 2,
				"POINT": {
					"Point1": {
						"X": 1942.6468505859375,
						"Y": 2344.69677734375,
						"Z": 0
					},
					"Point2": {
						"X": 3313.0263671875,
						"Y": 2062.294189453125,
						"Z": 0
					}
				},
				"Type": "LINE"
			},
			"Layer": "WALL_T"
		}
	]
}

and

{
	"Data": {
		"Count": 2,
		"POINT": {
			"Point1": {
				"X": 2015.12353515625,
				"Y": 2028.6619873046875,
				"Z": 0
			},
			"Point2": {
				"X": 2967.66357421875,
				"Y": 1559.193359375,
				"Z": 0
			}
		},
		"Type": "LINE"
	},
	"Layer": "WALL_T"
}

i want to add second string in first "wall" array..
result be like ..

{
	"WALL": [
		{
			"Data": {
				"Count": 2,
				"POINT": {
					"Point1": {
						"X": 1942.6468505859375,
						"Y": 2344.69677734375,
						"Z": 0
					},
					"Point2": {
						"X": 3313.0263671875,
						"Y": 2062.294189453125,
						"Z": 0
					}
				},
				"Type": "LINE"
			},
			"Layer": "WALL_T"
		},
		{
			"Data": {
				"Count": 2,
				"POINT": {
					"Point1": {
						"X": 2015.12353515625,
						"Y": 2028.6619873046875,
						"Z": 0
					},
					"Point2": {
						"X": 2967.66357421875,
						"Y": 1559.193359375,
						"Z": 0
					}
				},
				"Type": "LINE"
			},
			"Layer": "WALL_T"
		}
	]
}
@nlohmann
Copy link
Owner

Assuming your first value is called j and the second value is called k

j["WALL"].push_back(k);

will add k to the array at key "WALL" of j.

@nlohmann nlohmann added kind: question solution: proposed fix a fix for the issue has been proposed and waits for confirmation labels Mar 13, 2018
@nlohmann
Copy link
Owner

@Mamlesh Do you need further assistance?

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