A
ashuthinks32
Guest
I have 3 api calls which gives me 3 separate json output
api 1 output
{
"demo": {
"results": [
{
"__metadata": {
"id": "",
"uri": "",
"type": "ABC.MasterData"
},
"part1": {
"__metadata": {
"type": "ABC.MasterData_demo"
},
"location": "df393"
},
"Identifier": "987",
"Name": "dex"
}
]
}
}
api 2 output -
{
"demo": {
"results": [
{
"__metadata": {
"id": "",
"uri": "",
"type": "xc.Level"
},
"Id": "4545",
"Level": "f1"
},
{
"__metadata": {
"id": "",
"uri": "",
"type": "xc.Level"
},
"Id": "6786",
"Level": "f4"
}
]
}
}
api 3 ouput -
{
"demo": {
"results": [
{
"__metadata": {
"id": "",
"uri": "",
"type": "bn.Dim"
},
"Id": "454",
"Created": "2019-03-02"
},
{
"__metadata": {
"id": "",
"uri": "",
"type": "bn.Dim"
},
"Id": "676",
"Created": "2019-04-21"
}
]
}
}
I have de-serialized the output into c# class
var api1 = JsonConvert.DeserializeObject<Api1Class>(api1JsonOutput);
var api2 = JsonConvert.DeserializeObject<Api2Class>(api2JsonOutput);
var api3 = JsonConvert.DeserializeObject<Api3Class>(api3JsonOutput);
But i want to merge the output under one single node I tried like below but failed.
var output = JsonConvert.SerializeObject(api.demo) + "\n" + JsonConvert.SerializeObject(api2.demo) + "\n" + JsonConvert.SerializeObject(api3.demo);
Desired output json should looks like-
{
"MasterData": {
"part1": {
"location": "df393"
},
"Identifier": "987",
"Name": "dex",
"Level": [
{
"Id": "4545",
"Level": "f1"
},
{
"Id": "6786",
"Level": "f4"
}
],
"Dim": [
{
"Id": "454",
"Created": "2019-03-02"
},
{
"Id": "676",
"Created": "2019-04-21"
}
]
}
}
SE
Continue reading...
api 1 output
{
"demo": {
"results": [
{
"__metadata": {
"id": "",
"uri": "",
"type": "ABC.MasterData"
},
"part1": {
"__metadata": {
"type": "ABC.MasterData_demo"
},
"location": "df393"
},
"Identifier": "987",
"Name": "dex"
}
]
}
}
api 2 output -
{
"demo": {
"results": [
{
"__metadata": {
"id": "",
"uri": "",
"type": "xc.Level"
},
"Id": "4545",
"Level": "f1"
},
{
"__metadata": {
"id": "",
"uri": "",
"type": "xc.Level"
},
"Id": "6786",
"Level": "f4"
}
]
}
}
api 3 ouput -
{
"demo": {
"results": [
{
"__metadata": {
"id": "",
"uri": "",
"type": "bn.Dim"
},
"Id": "454",
"Created": "2019-03-02"
},
{
"__metadata": {
"id": "",
"uri": "",
"type": "bn.Dim"
},
"Id": "676",
"Created": "2019-04-21"
}
]
}
}
I have de-serialized the output into c# class
var api1 = JsonConvert.DeserializeObject<Api1Class>(api1JsonOutput);
var api2 = JsonConvert.DeserializeObject<Api2Class>(api2JsonOutput);
var api3 = JsonConvert.DeserializeObject<Api3Class>(api3JsonOutput);
But i want to merge the output under one single node I tried like below but failed.
var output = JsonConvert.SerializeObject(api.demo) + "\n" + JsonConvert.SerializeObject(api2.demo) + "\n" + JsonConvert.SerializeObject(api3.demo);
Desired output json should looks like-
{
"MasterData": {
"part1": {
"location": "df393"
},
"Identifier": "987",
"Name": "dex",
"Level": [
{
"Id": "4545",
"Level": "f1"
},
{
"Id": "6786",
"Level": "f4"
}
],
"Dim": [
{
"Id": "454",
"Created": "2019-03-02"
},
{
"Id": "676",
"Created": "2019-04-21"
}
]
}
}
SE
Continue reading...