Passing JSON files as command values?

Milena

The woman of many questions
Veteran
Joined
Jan 26, 2014
Messages
1,282
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,600
Reaction score
2,359
First Language
French
Primarily Uses
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
856
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

"If the lion knew her own strength, hard were it for anyone to rule her". This would be my custom title if I had enough spaces for it. Coming off of personal pain, I'm glad I found the original quote I've tweaked.
Today I found out that ladybirds\ladybugs are apparently named for the Virgin Mary. They're also known as God's cows in some places.
J0pac wrote on CrowStorm's profile.
The sad reaction was not because I want you to credit me. (terms clearly say no need to credit) but because those maps are meant to be used as inspiration or guidence. You are ofcourse alowed to use them however you want :)
I'm an adult married woman

Forum statistics

Threads
93,452
Messages
912,525
Members
122,977
Latest member
Midgar21
Top