Hallo, zum Bleistift habe ich jetzt:
json-Format:
{ "search" : { "credit" : { "info" : "In order to use the free weather data from wetter.com you HAVE TO display at least two out of three of the following possibilities: text, link, logo",
"link" : "http://www.wetter.com",
"logo" : "Download at http://www.wetter.com/api/downloads/#logos",
"text" : "Powered by wetter.com"
},
"exact_match" : true,
"hits" : 1,
"maxhits" : 30,
"result" : [ { "adm_1_code" : "DE",
"adm_2_name" : "Niedersachsen",
"adm_4_name" : "Stade",
"city_code" : "DE0001740",
"name" : "Buxtehude",
"plz" : "21614",
"quarter" : ""
} ],
"search_string" : "Buxtehude"
} }
(formatiert, aber wenig Overhead)
Daraus möchte ich jetzt zwei Dinge/Sachen machen,
- alle Name und Wert (Attribute oder so in json) einmal durchgehen und Zeichenkette erstellen,
- Java-Objekte erstellen,
- eine Liste mit Java-Objekten erstellen.
Wie muss ich da vorgehen (bei generell)?
Danke, Grüße, Cyborg. :rolleyes: :twisted:
*** Edit ***
zB hab ich jetzt:
public static class Credit {
public String info;
public String link;
public String logo;
public String text;
}
public static class Result {
public String adm_1_code;
public String adm_2_name;
public String adm_4_name;
public String city_code;
public String name;
public int plz;
public String quarter;
}
public Credit credit;
public boolean exact_match;
public int hits;
public int maxhits;
public List<Result> result;
public String search_string;
}```
``` String str = ...;
System.out.println("str = " + str);
Gson gson = new GsonBuilder().create();
Search ser = gson.fromJson(str, Search.class);
System.out.println("ser = " + ser);```
aber alles null bzw. 0 (auch keine Ausgabe). Was ist daran falsch?