Jump to content

[1.9.4] Parse a JSON File for strings


james090500

Recommended Posts

Hello!

 

I'm extremely stuck, I've been testing and trying for 8 hours but I'm going no where.

 

I need my mod to read a json file which contains information about players. I need it to be able to do this....

 

 

JSON

"Player1": [
"status": "offline",
"mode": "null",
"server": "null"
]

"Player2": [
"status": "online",
"mode": "single",
"server": "null"
]

"Player3": [
"status": "online",
"mode": "mp",
"server": "mc.Example.net"
]

JSON json = new JSON(new FileReader("file.json"));
List<String> names = new ArrayList<String>();
String line = json.getTitles(); <-- Get Player1, Player2, Player3
while(line !=null)
       results.add(line);
}

--- AND ---

JSON json = new JSON(new FileReader("file.json"));
List<String> names = new ArrayList<String>();
String line = json.getOptions("status"); <-- Get Offline, Online, online (Stay in order like above)
while(line !=null)
       results.add(line);
}

 

is this possible?

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.