Hey,
ich wollte mal kurz fragen wie es den möglich ist von einer Json datei die daten auszulesen.
Als beispiel ich habe diese Datei :
Wie könnte ich dabei jetzt zb die versions nummer abrufen?
// Edit soweit hab ich es schon:
ich wollte mal kurz fragen wie es den möglich ist von einer Json datei die daten auszulesen.
Als beispiel ich habe diese Datei :
Code:
[{"map":{"infos":{"name":"Wald","version":"1.0","authores":"MrKavatch / MisterQuatsch"},"teams":{"gelb":{"spawn":{"x":"-40","y":"81","z":"-208"},"protection":{"center":{"x":"-16","z":"-213"},"radius":"35"}},"grün":{"spawn":{"x":"266","y":"64","z":"-510"},"protection":{"center":{"x":"264","z":"-495"},"radius":"30"}}},"kit":{"slot":{"slot1":{"item":"WOOD_SWORD","ammount":"1","meta":"0"},"slot2":{"item":"STONE_PICKAXE","ammount":"1","meta":"0"},"slot3":{"item":"APPLE","ammount":"16","meta":"0"},"slot4":{"item":"LOG","ammount":"32","meta":"0"},"slot5":{"item":"AIR","ammount":"1","meta":"0"},"slot6":{"item":"AIR","ammount":"1","meta":"0"},"slot7":{"item":"AIR","ammount":"1","meta":"0"},"slot8":{"item":"AIR","ammount":"1","meta":"0"},"slot9":{"item":"AIR","ammount":"1","meta":"0"},"helmet":{"item":"AIR","ammount":"1","meta":"0"},"chestplate":{"item":"LEATHER_CHESTPLATE","ammount":"1","meta":"0"},"leggings":{"item":"LEATHER_LEGGINGS","ammount":"1","meta":"0"},"boots":{"item":"LEATHER_BOOTS","ammount":"1","meta":"0"}},"extras":{"effects":{"effect1":{"type":"DAMAGE_RESISTANCE","lenght":"25","strength":"200"},"effect2":{"type":"BLINDNESS","lenght":"2","strength":"10"},"effect3":{"type":"SATURATION","lenght":"100","strength":"10"}}}},"filer":{"blocks":{"noPlace":{"errorMsg":"§cDu darfst diesen Block nicht Setzen!"},"noBreak":{"errorMsg":"§cDu darfst diesen Block nicht Zerstören!"}}}}}]
// Edit soweit hab ich es schon:
Code:
public class Json {
private final static JSONParser jsonParser = new JSONParser();
static JSONArray array;
public static void main(String[] args) throws IOException, ParseException {
URL oracle = new URL("http://www.greev.eu/Json/map");
BufferedReader in = new BufferedReader(new InputStreamReader(oracle.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
array = (JSONArray) jsonParser.parse(inputLine);
System.out.println(inputLine);
}
in.close();
JSONObject jsonProfile = (JSONObject) array.get(0);;
String name = (String) jsonProfile.get("version");
System.out.println("NAME >>> " + name);
}
}