简体   繁体   中英

How to parse JSON data without key names into a Java class structure?

I successfully followed the example Simple Spring code to parse JSON into a Java class structure using Jackson.

Now i am looking for a hint how to do the same for JSON data without key names, eg

{
    "10869918": {
        "BRANCH": "Dienstleistungen", 
        "SECTOR": "Diverse"
    }, 
    "12254991": {
        "BRANCH": "Luft- und Raumfahrtindustrie", 
        "SECTOR": "Logistik"
    }, 
    "12302743": {
        "BRANCH": "Touristik und Freizeit", 
        "SECTOR": "Medien/Freizeit"
    }
}

I doubt this is possible with a POJO-JSON mapper. You could use libraries like json-simple to parse the JSON string into Java objects (which basically are maps and lists) and access values like "10869918" by reading the keys of those maps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM