【发布时间】:2021-07-26 23:32:51
【问题描述】:
这是我尝试反序列化的 Json 部分的示例,我还需要能够通过 POST 发送类似的 Json。问题是我不确定我应该如何读取所有这些对象并将它们添加到特定的“adocumentitems”对象列表中,而不是将其序列化为 JSON 格式的那种类型的对象列表。
{
"adocumentitems":{
"0":{
"sdescription":"PORTÁTILES SIN FLUOROSCOPIA E INTENSIFICADOR DE IMÁGENES PRACTICADO EN HABITACION UCI RN O QUIRÓFANOS",
"sstandarditemidentification":"21601_03 - 21601",
"nunitprice":21854,
"ntotal":21854,
"nquantity":1,
"sgroupname":"TIPO DE INGRESO: URGENCIAS Fecha Ing: 2021-04-09 15:27:49 Fecha Egr: 2021-04-11 22:03:00 AUTORIZACION: 146693312"
},
"1":{
"sdescription":"RADIOGRAFIA DE TORAX P.A.O A.P.Y LATERAL DECUBITO LATERAL OBLICUAS O LATERAL CON BARIO",
"sstandarditemidentification":"871121_03 - 871121",
"nunitprice":28924,
"ntotal":28924,
"nquantity":1,
"sgroupname":"TIPO DE INGRESO: URGENCIAS Fecha Ing: 2021-04-09 15:27:49 Fecha Egr: 2021-04-11 22:03:00 AUTORIZACION: 146693312"
},
"2":{
"sdescription":"TOMOGRAFIA AXIAL COMPUTADA DE TORAX",
"sstandarditemidentification":"879301_03 - 879301",
"nunitprice":141386,
"ntotal":282772,
"nquantity":2,
"sgroupname":"TIPO DE INGRESO: URGENCIAS Fecha Ing: 2021-04-09 15:27:49 Fecha Egr: 2021-04-11 22:03:00 AUTORIZACION: 146693312"
},
"3":{
"sdescription":"CONSULTA DE PRIMERA VEZ POR ESPECIALISTA EN MEDICINA INTERNA",
"sstandarditemidentification":"890266_03 - 890266",
"nunitprice":17514,
"ntotal":17514,
"nquantity":1,
"sgroupname":"TIPO DE INGRESO: URGENCIAS Fecha Ing: 2021-04-09 15:27:49 Fecha Egr: 2021-04-11 22:03:00 AUTORIZACION: 146693312"
},
"4":{
"sdescription":"CUIDADO MANEJO INTRAHOSPITALARIO POR MEDICINA ESPECIALIZADA",
"sstandarditemidentification":"890602_03 - 890602",
"nunitprice":21133,
"ntotal":42266,
"nquantity":2,
"sgroupname":"TIPO DE INGRESO: URGENCIAS Fecha Ing: 2021-04-09 15:27:49 Fecha Egr: 2021-04-11 22:03:00 AUTORIZACION: 146693312"
},
"5":{
"sdescription":"CONSULTA DE URGENCIAS POR MEDICINA GENERAL",
"sstandarditemidentification":"890701_03 - 890701",
"nunitprice":17395,
"ntotal":17395,
"nquantity":1,
"sgroupname":"TIPO DE INGRESO: URGENCIAS Fecha Ing: 2021-04-09 15:27:49 Fecha Egr: 2021-04-11 22:03:00 AUTORIZACION: 146693312"
},
"6":{
"sdescription":"HEMOCULTIVO AEROBIO POR METODO AUTOMATICO",
"sstandarditemidentification":"901221_03 - 901221",
"nunitprice":42560,
"ntotal":85120,
"nquantity":2,
"sgroupname":"TIPO DE INGRESO: URGENCIAS Fecha Ing: 2021-04-09 15:27:49 Fecha Egr: 2021-04-11 22:03:00 AUTORIZACION: 146693312"
},
"7":{
"sdescription":"HEMOGRAMA IV [HEMOGLOBINA HEMATOCRITO RECUENTO DE ERITROCITOS-INDICES ERITROCITARIOS-LEUCOGRAMA-RECUENTO DE PLAQUETAS-INDICES PLAQUETARIOS Y MORFOLOGIA ELECTRONICA E HISTOGRAMA] METODO AUTOMATICO",
"sstandarditemidentification":"902210_03 - 902210",
"nunitprice":15421,
"ntotal":15421,
"nquantity":1,
"sgroupname":"TIPO DE INGRESO: URGENCIAS Fecha Ing: 2021-04-09 15:27:49 Fecha Egr: 2021-04-11 22:03:00 AUTORIZACION: 146693312"
},
"8":{
"sdescription":"GASES ARTERIALES EN REPOSO O EN EJERCICIO",
"sstandarditemidentification":"903839_03 - 903839",
"nunitprice":17766,
"ntotal":35532,
"nquantity":2,
"sgroupname":"TIPO DE INGRESO: URGENCIAS Fecha Ing: 2021-04-09 15:27:49 Fecha Egr: 2021-04-11 22:03:00 AUTORIZACION: 146693312"
},
"9":{
"sdescription":"HABITACION DE CUATRO CAMAS O MAS",
"sstandarditemidentification":"10A004_03 - S11304",
"nunitprice":91966,
"ntotal":183932,
"nquantity":2,
"sgroupname":"TIPO DE INGRESO: URGENCIAS Fecha Ing: 2021-04-09 15:27:49 Fecha Egr: 2021-04-11 22:03:00 AUTORIZACION: 146693312"
},
"10":{
"sdescription":"OXIGENO CATETER O CANULA NASAL X HORA",
"sstandarditemidentification":"S55201_03 - S55201",
"nunitprice":2940,
"ntotal":152880,
"nquantity":52,
"sgroupname":"TIPO DE INGRESO: URGENCIAS Fecha Ing: 2021-04-09 15:27:49 Fecha Egr: 2021-04-11 22:03:00 AUTORIZACION: 146693312"
},
"11":{
"sdescription":"ACIDO ACETIL SALICILICO 100 mg TABLETA",
"sstandarditemidentification":"19936296-08",
"nunitprice":100,
"ntotal":200,
"nquantity":2,
"sgroupname":"TIPO DE INGRESO: URGENCIAS Fecha Ing: 2021-04-09 15:27:49 Fecha Egr: 2021-04-11 22:03:00 AUTORIZACION: 146693312"
}
}
我所知道的 JSON 列表的类型看起来更像这样:
{ "adocumentitems": [
{
"sdescription":"PORTÁTILES SIN FLUOROSCOPIA E INTENSIFICADOR DE IMÁGENES PRACTICADO EN HABITACION UCI RN O QUIRÓFANOS",
"sstandarditemidentification":"21601_03 - 21601",
"nunitprice":21854,
"ntotal":21854,
"nquantity":1,
"sgroupname":"TIPO DE INGRESO: URGENCIAS Fecha Ing: 2021-04-09 15:27:49"
},
{
"sdescription":"PORTÁTILES SIN FLUOROSCOPIA E INTENSIFICADOR DE IMÁGENES PRACTICADO EN HABITACION UCI RN O QUIRÓFANOS",
"sstandarditemidentification":"21601_03 - 21601",
"nunitprice":21854,
"ntotal":21854,
"nquantity":1,
"sgroupname":"TIPO DE INGRESO: URGENCIAS Fecha Ing: 2021-04-09 15:27:49"
} ]
}
但事实并非如此……
我正在使用 C#,尝试对其进行反序列化并使用 NewtonSoft 对其进行序列化。
将对象序列化为 Json 以用于 POST 目的
var JsonData = JsonConvert.SerializeObject(adocumentitems);
在执行 GET 时反序列化对对象的 json 响应
return JsonConvert.DeserializeObject<adocumentitems>(JsonGetResponse);
如果有人能帮助我了解如何处理这种类型的 json 列表,我将不胜感激。
【问题讨论】:
-
这能回答你的问题吗? json deserialization to C#