nstgc Posted May 15, 2018 Posted May 15, 2018 (edited) So I learned that game data files are in JSON string format. That was great. What wasn't so great was looking at an insanely long string. When I asked what tools were used I was told Notepad++ with the JSON plug-in, but this didn't work. I then did searches and tried Vim (my choice of editor anyway) and Geany plugins. No luck. I settled on https://jsoneditoronline.org/ for viewing, but I really don't want to rely so heavily on an online editor. What this online editor allows however is to beautify the string into something that is easier for humans to read. This allows one to copy and paste the text beautified text on the left into your text editor of choice. In the smallest of these pictures you see the two option buttons. Clicking the one of the left makes the text easier on the eyes. Note that most people probably can just use Notepad++ with the JSON plugin. Even if it worked for me, I would prefer the below. Another option for those comfortable with terminals (this is what I'll be doing) you can do the following. tail -c +4 FILE.gamedatabundle | python -m json.tool > FILE.mod.gamedatabundle This probably doesn't work in Windows (but of course Notepad++ probably will), but it should work on Macs, and I know it works in GNU/Linux. Once converted you can use your favorite editor to edit it. Tail removes the BOM header which interferes with the python script which does the actual conversion. A nice bash script would then be #!/bin/bash tail -c +4 $1.gamedatabundle | python -m json.tool > $1.mod.gamedatabundle vim $1.mod.gamedatabundle or whatever your editor of choice is, so long as it's not Emacs. Emacs will not work. It won't! Don't even try it. (this is a joke; I hate Emacs with a passion.) Alternatively, you can use Vim and run :set nobomb then %!python -m json.tool. This may or may not work in Windows. No clue about Mac. In any case, I like the one line conversion, and the script even better. In any case, I have a picture of what it looks like for me in Vim. I created a file ~/.vim/ftdetect/gamebundledata with set syntax=json fdm=syntax which produces the desired result. fdm=indent would likely be faster, but this is more certain. I don't know what the equivalent Windows method would be, but I think that there is an ~/.vim folder on Macs, and if not, there should be one that is equivalent. fireundubh suggested PyCharm, and IDE which can help clean up some of the formatting issues in the files. The python script I suggest running will point you towards a solution, but apparently the IDE will actually highlight them. Edited May 16, 2018 by nstgc 1
TKDancer Posted May 15, 2018 Posted May 15, 2018 (edited) i just installed the JSON viewer plugin and used the "format JSON" option under the plugin tab, worked for me EDIT: nvm seems that saving the file with the formated form makes game not work properly Edited May 15, 2018 by TKDancer
nstgc Posted May 15, 2018 Author Posted May 15, 2018 (edited) i just installed the JSON viewer plugin and used the "format JSON" option under the plugin tab, worked for me Yeah, I know. It doesn't work for me. I'm providing an alternative for those whom have the same problem. The pluggin installs, but when it tries reading the bundles it returns an error. In any case, I found a solution that works perfectly for me. Edited May 15, 2018 by nstgc
fireundubh Posted May 16, 2018 Posted May 16, 2018 In PyCharm, you just press Ctrl+Alt+L. Note that some of the JSON files are not formatted correctly to begin with, so it's useful to have an IDE, like PyCharm, that will highlight the errors so you can fix them before trying to pretty print them. The JSON library that OEI uses is a lot more tolerant of these errors than pretty printers, so they're not issues in the game.
nstgc Posted May 16, 2018 Author Posted May 16, 2018 In PyCharm, you just press Ctrl+Alt+L. Note that some of the JSON files are not formatted correctly to begin with, so it's useful to have an IDE, like PyCharm, that will highlight the errors so you can fix them before trying to pretty print them. The JSON library that OEI uses is a lot more tolerant of these errors than pretty printers, so they're not issues in the game. Nice! I've been finding and fixing those by hand. items.gamedatabundle needed some find and replace (to get rid of some commas), and global has two lines. However the python script is good about telling me what's wrong. Still, that would make life easier.
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