DynamicJson icon indicating copy to clipboard operation
DynamicJson copied to clipboard

Cannot process JSON with numbers as keys

Open whc2001 opened this issue 7 years ago • 1 comments

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.

whc2001 avatar Jul 10 '18 20:07 whc2001

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.

hikono avatar Dec 21 '18 02:12 hikono