DynamicJson
DynamicJson copied to clipboard
Cannot process JSON with numbers as keys
I tried to process the JSON below:
{
"party": {
"1": {
"party_no": "1",
"status": "1",
"party_name": "第1部隊",
"finished_at": null,
"slot": {
"1": {
"serial_id": "11111111",
"sword_id": "44"
},
"2": {
"serial_id": "22222222",
"sword_id": "84"
},
"3": {
"serial_id": "33333333",
"sword_id": "12"
},
"4": {
"serial_id": "44444444",
"sword_id": "40"
},
"5": {
"serial_id": "55555555",
"sword_id": "34"
},
"6": {
"serial_id": "66666666",
"sword_id": "50"
}
}
}
}
}
When I tried to get json["party"]["1"]["party_name"].ToString(), an System.Xml.XmlException was thrown that says the name cannot begin with "1". Seems like XML has a restriction. I wonder if this can be solved in some way. Thanks.
I wanted to parse swagger's JSON.
https://swagger.io/docs/specification/using-ref/
I don't care DynamicJson cannot resolve reference.
But when I tried to resolve reference myself.
Just using IsDefined["$ref"], XmlException is thrown.