Добавьте одну строку json к другой как дочерний элемент C#
У меня есть две строки json, как показано ниже
{ "account-Ind": "A", "multipage-Ind": " ", "relat-Ch-St-Nmbr": "0000001", "relat-Claim-Nmbr": "0000000", "schg-Remit-Flag": " ", "schg-Mgcare": "000000000", "schg-Co-Pay": "000000000", "schg-Deductible": "000000000", "schg-Co-Ins": "000000000", "schg-Payment": "000000000", "schg-Tot-Claim": "000000000", "schg-Elig": " ", "filler1": " " }
а это вторая строка json
{ "message-Code-1": " ", "msg-Number-Pos1-1": " ", "msg-Number-Pos2-1": " ", "msg-Number-Pos3-1": " ", "message-Code-2": " ", "msg-Number-Pos1-2": " ", "msg-Number-Pos2-2": " ", "msg-Number-Pos3-2": " ", "message-Code-3": " ", "msg-Number-Pos1-3": " ", "msg-Number-Pos2-3": " ", "msg-Number-Pos3-3": " ", "message-Code-4": " ", "msg-Number-Pos1-4": " ", "msg-Number-Pos2-4": " ", "msg-Number-Pos3-4": " " }
Мне нужен вывод, как показано ниже
{ "account-Ind": "A", "multipage-Ind": " ", "relat-Ch-St-Nmbr": "0000001", "relat-Claim-Nmbr": "0000000", "schg-Remit-Flag": " ", "schg-Mgcare": "000000000", "schg-Co-Pay": "000000000", "schg-Deductible": "000000000", "schg-Co-Ins": "000000000", "schg-Payment": "000000000", "schg-Tot-Claim": "000000000", "schg-Elig": " ", "filler1": " ", "message-Table": { "message-Code-1": "0000", "msg-Number-Pos1": "1", "msg-Number-Pos2": "1", "msg-Number-Pos3": "1", "message-Code-2": "0001", "msg-Number-Pos1": "2", "msg-Number-Pos2": "1", "msg-Number-Pos3": "1", "message-Code-3": "0002", "msg-Number-Pos1": "2", "msg-Number-Pos2": "1", "msg-Number-Pos3": "1", "message-Code-4": "0004", "msg-Number-Pos1": "2", "msg-Number-Pos2": "1", "msg-Number-Pos3": "1", "message-Code-5": "0005", "msg-Number-Pos1": "2", "msg-Number-Pos2": "1", "msg-Number-Pos3": "1" } }
Что я уже пробовал:
var javaScriptSerializer = new JavaScriptSerializer(); var userDetails = javaScriptSerializer.DeserializeObject(json1); var messageTable = javaScriptSerializer.DeserializeObject(json2); var arrayOfObjects = JsonConvert.SerializeObject( new[] { JsonConvert.DeserializeObject(json1), JsonConvert.DeserializeObject(json2) }); return arrayOfObjects; But I getting result like below [ { "account-Ind": "A", "multipage-Ind": " ", "relat-Ch-St-Nmbr": "0000001", "relat-Claim-Nmbr": "0000000", "record-Type": "1", "record-Seq": "0000", "cert-Nmbr": "109085006", "provider-Charge": "000035000", "int-Amount-Paid": "0000000", "clm-Account-Nmbr": "HNY1002 ", "alt-Id": "931929156", "schg-Elig": " ", "filler1": " " }, { "message-Code-1": " ", "msg-Number-Pos1-1": " ", "msg-Number-Pos2-1": " ", "msg-Number-Pos3-1": " ", "message-Code-2": " ", "msg-Number-Pos1-2": " ", "msg-Number-Pos2-2": " ", "msg-Number-Pos3-2": " ", "message-Code-3": " ", "msg-Number-Pos1-3": " ", "msg-Number-Pos2-3": " ", "msg-Number-Pos3-3": " ", "message-Code-4": " ", "msg-Number-Pos1-4": " ", "msg-Number-Pos2-4": " ", "msg-Number-Pos3-4": " ", "message-Code-5": " ", "msg-Number-Pos1-5": " ", "msg-Number-Pos2-5": " ", "msg-Number-Pos3-5": " " } ]