Matzuake Posted February 9, 2020 Posted February 9, 2020 { "holz": [ { "itemname": "Eichenholz", "item": { "material": "OAK_LOG", "anzahl": "1" }, "lore": [ { "preis": "10" } ] }, { "itemname": "Brauner Pilzblock", "item": { "material": "BROWN_MUSHROOM_BLOCK", "anzahl": "1" }, "lore": [ { "preis": "15" } ] }, { "itemname": "Tropenbaumlaub", "item": { "material": "JUNGLE_LEAVES", "anzahl": "1" }, "lore": [ { "preis": "2" } ] }, { "itemname": "Eichenholz", "item": { "material": "OAK_LOG", "anzahl": "64" }, "lore": [ { "preis": "64" } ] }, { "itemname": "Eichenholz", "item": { "material": "OAK_LOG", "anzahl": "64" }, "lore": [ { "preis": "10" } ] }, { "itemname": "Brauner Pilzblock", "item": { "material": "BROWN_MUSHROOM_BLOCK", "anzahl": "64" }, "lore": [ { "preis": "960" } ] }, { "itemname": "Tropenbaumlaub", "item": { "material": "JUNGLE_LEAVES", "anzahl": "64" }, "lore": [ { "preis": "128" } ] } ] } ich würde gerne diese json datei in mein Plugin laden , nur die umsetzung ist etwas naja ich arbeite noch nicht solange mit Json Gson gson = new Gson(); ShopItems[] shopItems= gson.fromJson(json, ShopItems[].class); for(ShopItems shopItem: shopItems) System.out.println(shopItem.toString()); ich habe das so probiert aber ohne erfolg es kommt immer eine java.lang.NullPointerException
TileEntity Posted February 10, 2020 Posted February 10, 2020 Soll sich die Datei direkt im Plugin befinden oder soll sie aus dem Plugins-Ordner geladen werden? Was genau soll erst mal ausgegeben werden? Die ganze Datei als String oder bestimmte Objekte der Datei?
Matzuake Posted February 11, 2020 Author Posted February 11, 2020 hi , die datei liegt im Plugin ordner , und soll so ausgegbene werden das das als Obejct aus geben kann , damit ich das dann ins Inventar vom Shop packen kann
TileEntity Posted February 11, 2020 Posted February 11, 2020 Habe mal ein paar Sachen probiert - bei mir will es auch nicht klappen 😕 Es gibt ja Plugins, die auch Daten von einer Json abgreifen - evtl. findet man bei Github ein paar Beispiele bez. Umsetzung. Wegen dem parsen der Datei könnte evtl. das hier nützlich sein: https://gist.github.com/DevSrSouza/aa2f39fb2299dfe72b49b52fa46d9a73
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now