Posted October 22, 20159 yr So basically, I want to use .json files to store some data for my waypoints instead of using a .txt file like I do now. Now I have never used a .json file before, only edited one for blocks & items/models etc. I have a List that stores all of my waypoints, what I am wondering is how would I go about saving data to a .json file, then read that data to create a waypoint that is then added to the list. Also the main way I would also like to know is how I would format the file to look a bit like this but for every waypoint created: { { "name": "Whateverthenameis", "symbol": "SymbolLetter", "properties": [ "coordinates": [ "x": whateverx, "y": whatevery, "z:" whateverz ], "type": whatevertype, "scale": whateverscaleasfloat, "shown": whatevershown, ], "world": "WorldFrom" }, }
October 22, 20159 yr You need a json serializer/deserializer, don't try to write such a thing yourself. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
October 22, 20159 yr What Draco said. You can try the GSON library from Google, which should already be included in the workspace. Note that .JSON is technically just text with a specific format - it is often used, for example, to serialize data for storage in a database (e.g. MySQL) or to transmit over a network (e.g. for an AJAX operation). The major benefit of it is that it facilitates the serialization of complex objects or arrays as simple text. http://i.imgur.com/NdrFdld.png[/img]
October 22, 20159 yr Author I am aware I need those, but the main thing I am wondering is how to basically read/write the data from/to the json, and create variables for each read value, then convert that into a waypoint with the values.
October 22, 20159 yr I think the specifications here are what you're looking for. In other words, in json you have "objects" (they act more like hashmaps, but still). They are enclosed in curly brackets ({}). Each pair consists of a string (a key/field name), and a value (string representation of your data), with a colon ( inbetween them. Commas are sometimes used to separate the key-value pairs. Arrays also exist, and are enclosed in brackets ([]). They contain a list of values, separated by commas. Currently working on a mod to provide support for the Clojure programming language in Minecraft, check it out here.
October 22, 20159 yr Author I know, but the thing is, is how would I go about reading/writing from/to the .json file
October 23, 20159 yr [lmgtfy]Gson tutorial[/lmgtfy] Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.