Passing JSON files as command values?

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,281
Reaction score
106
First Language
Irish
Primarily Uses
N/A
I have a few questions about JSON. My idea is that I want to make a set of commands based mainly on a JSON file. The JSON file should have the following:

  • value of name
  • value of first number named level
  • value of second number called rank

Now, inside the plugin, I want to read the JSON and pass it as commands from window commands. So I want to know the following:


1. How can I get the length of those value from the JSON if we consider that the values are made like a hash? What I mean by this is like, what if, 


whole JSON Files = {


:first_enemy = [level, rank],


:second_enemy = [level, rank]


}


I am setting this example from RPG Maker VX Ace scripting experience. Please correct me if JSON does not work this way.


2. I want to set the value of name as command name, the value of the level as level and rank as rank. So in any sense, I want the JSON to handle the commands or how many commands is shown inside the plugin.


Thank you in advance.
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
they do not work like that


JSON work in this scheme.


{
"1" :{
"craftName" : "smithery",
"craftTime" : 30,
"bufferTIme" : 90,
"expTable" : [10,5,12,20],
"maxLevel" : 10,
"rankName" : ["noob","somewhat good", "aprentice","master smith"],
"backImg" : "",
"SceneMusic" : "",
"craftSound" : [],
"ActiveSound" : ["hammer",100,100,1]
}
}


and for get the command in order you would need to split them via a Loop.


EG I don't quite remember how to do that but I think using a array would do the job
 
Last edited by a moderator:

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
863
First Language
German
Primarily Uses
JSON.parse(...) can be used to parse the contents of a json file as a JS object.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,083
Members
137,583
Latest member
write2dgray
Top