Using JSON content in Database

Hello !

My question is pretty simple, though I don't know how to do it :

I have a JSON reader that puts my whole JSON into a hash so I can get any item when I want (for example, if I want to know the name of the potion, I just have to use my hash["potion"].

So everything works, but I can't find a way to modify names into the database depending on the JSON. I saw in the DataManager that there is a $data_items holding a list of RPG::Items, though I can't find a way to get the definition of that class and I don't know how to access its name. It's the same for any other element in the database. I tried to change some parts of the Vocab so it works, but it looks like the whole database vocabulary is not stored here (like all the stuff names, item names, ...)

Can anyone please help me ?

Thanks in advance.
'Scripts' is the section where people who have written a script that they want to share with the community can post it. It is also for VX Ace, which is written in RGSS3, not Javascript.

Moved to: Javascript/Plugin Support

EDIT
Wait... I was going by your reference to JSON which I thought was a Javascript/MV element, but I now see that you have VX Ace set as the engine you are using, in which case, this needs to be in RGSSx Support. Would you please clarify whether this is being written in RGSS3 or in Javascript.
The script is written in RGSS3, but I'm using a JSON to hold my data 😀 So yeah, it belongs in the RGSSx Support ^^
Sorry for the wrong section, I didn't find the right one D:
Moderator note: Moving this to RGSSx Script Support
You are doing exactly what with that JSON data?
What do you store in that JSON data? When and how? And for what purpose?

All of the database items are being loaded only once on startup from the files found in the Data folder of your project.
Modifying their names would mean nothing if you only do that, since their names will be reset every time you restart the game.
You would need to rewrite the way the database works, store their initial data in a separate variable (or in more variables) and save these new variables with the save file itself (only save what you want to modify during the game), and modify whatever you need in these new variables instead of the real data files. This way, you can keep the changes even if you restart and/or reload a saved game.
Note that saving all of the database files with the save files will increase the size of the save files by a lot, so it is not recommended.

Still not sure what do you want to achieve by using JSON in Ruby environment. Ruby got a Hash class by default, so you can make key + value pairs with that too.
Unless you are working on some online related data sending, in which case I still don't know what exactly you want to change... The real database files (for database editing purposes from outside of the engine), or the data of these database items during the game (and this is the case where you would need to store any data you want to modify and keep during the game in the save files).

You wrote that your "reader" puts all of your JSON into a hash. But why would you do that? JSON format is an effective hash itself, so you put a hash into a hash?
Maybe I'm misunderstood something, and if that's the case, sorry. I just can't wrap my head around this, can't see any benefit of doing what you do (or what I think you do).

In any case, if you want to look at the RPG::Class_Name classes, you can open the help files and check all of them under the Index tab.
Hello and thanks for your reply!

I should've said it in my first post, sorry about that. The JSON data I use is made to use the game in different languages, and as the project is supposed to be commercial at the end, I couldn't use a script I found earlier. So I try to make it in my own way.
So the content of the data is "keyword":"translation" for each text element of the game. It was easy to translate the interface parts and everything, but I can't find the database names.

Sure, it will be reloaded at every start : but that's intended, I can change it easily if I need to if it load at every start (and let's say it, reading a json at every start and storing it into a hash doesn't take that much resources).

Also, it's true that the JSON is kind of unnecessary, I could do so only with a hash (and it would've saved me the json reading trouble), but I feel like it's clearer to store everything into a JSON. Maybe will I change it later, but it won't change much in the code. So I can change that at any time.

And when I say I put my JSON into a hash, I mean that my reader takes a key, puts the key and the value into the hash, and so on : that way, I have the exact JSON into my hash, like let's say if I have a "Title":"To Title" line in my JSON, I'd be able to access it with hash["Title"].

And thank you for the help files. I didn't know them, I'm going to take a look there ! 😀

EDIT : Thanks so much for the tip! Looks like it's solved, I just needed to take every element of the array and change its name and description attributes 😀
Thread closed IgnoreMe

Original thread: https://forums.rpgmakerweb.com/threads/using-json-content-in-database.85781/