[
{
"mcClaimModelInfoId":{
"claim_no":"1019",
"sno":1,
"policy_no":"STC1001674000100"
},
"model_type":"1",
"vehicle_count":"100",
"remarks":"null",
"status":"null",
"entry_date":null
},
{
"mcClaimModelInfoId":{
"claim_no":"1019",
"sno":2,
"policy_no":"STC1001674000100"
},
"model_type":"1",
"vehicle_count":"10",
"remarks":"null",
"status":"null",
"entry_date":null
},
{
"mcClaimModelInfoId":{
"claim_no":"1019",
"sno":3,
"policy_no":"STC1001674000100"
},
"model_type":"8",
"vehicle_count":"5454",
"remarks":"null",
"status":"null",
"entry_date":null
}
]
答案 0 :(得分:0)
python中的示例:
import json
def test():
model = ''' [{"mcClaimModelInfoId":{"claim_no":"1019","sno":1,"policy_no":"STC1001674000100"},"model_type":"1","vehicle_count":"100","remarks":"null","status":"null","entry_date":null}] '''
return json.loads(model)
test_one = test()
for m in test_one:
print(m['mcClaimModelInfoId])
这是一个如何在python中进行操作的示例,您正在遍历json。 您可以使用Java或任何其他语言执行相同的操作。
json_line = line['mcClaimModelInfoId']['claim_no'] => 1019 (example)
答案 1 :(得分:0)
好吧,既然如此,您所显示的只是一个数组,如果...您想要在c#中进行访问和迭代的示例,这里有一种简单的方法:
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
JObject objTemp = JObject.Parse(yourJSON); //Converts the JSON to a JObject
JArray arr = JArray.Parse(objTemp["ArrayName"].ToString());
foreach (var arrElement in arr)
{
var x = (string)arrElement["mcClaimModelInfoId"]["model_type"];
}