I have two JObject
's loaded from the following two JSON files:
{
"data": {
"organism": {
"human": [
{
"firstName": "John",
"lastName": "Doe"
}
]
}
}
}
{
"degrees": [
{
"type": "bachelor",
"major": "Math"
},
{
"type": "master",
"major": "Computer Science"
}
]
}
I want to combine them into one JObject
like this:
{
"data": {
"organism": {
"human": [
{
"firstName": "John",
"lastName": "Doe",
"degrees": [
{
"type": "bachelor",
"major": "Math"
},
{
"type": "master",
"major": "Computer Science"
}
]
}
]
}
}
}
I have tried to add them as new field like this, but I am getting an error that i can't add JObject
to another JObject
:
jObject1["data"]["organism"]["human"][0]["lastName"].Parent.AddAfterSelf(jObject2)
I then tried to add it using JProperty
but it just added a duplicate field which is not the format I need.
jObject1["data"]["organism"]["human"][0]["lastName"].Parent.AddAfterSelf(new JProperty("degrees",jobject2))
I am not sure how to proceed from this.