Ho ottenuto GSON come parser JSON in Java, ma le chiavi non sono sempre le stesse.
Ad esempio. Ho il seguente JSON:Java GSON: Ottenere l'elenco di tutte le chiavi in un JSONObject
{ "l'oggetto so già": {
"key1": "value1",
"key2": "valore2",
"AnotherObject": { " anotherKey1 ":" anotherValue1" , "anotherKey2": "anotherValue2"}}
ho già ottenuto il JSONObject "l'oggetto so già". Ora ho bisogno di ottenere tutti i JSONElements per questo oggetto, questo sarebbe "Key1", "Key2" e "AnotherObject".
Grazie in anticipo.
EDIT: L'output dovrebbe essere una matrice di stringhe con tutte le chiavi per la JSONObject
possibile duplicato di [ Come decodificare JSON con campo sconosciuto usando Gson?] (Http://stackoverflow.com/questions/20442265/how-to-decode-json-with-unknown-field-using-gson) – pkubik
questo potrebbe essere utile http://stackoverflow.com/questions/14619811/retrieving-all-the-keys-in-a-ested-json-in-java –
quale dovrebbe essere il risultato finale? dovrebbe essere, '" key1 "," key2 "," AnotherObject "' OR '" L'oggetto so già "," key1 "," key2 "," AnotherObject "' ?? –