Passing JSON files as command values?

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.
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
JSON.parse(...) can be used to parse the contents of a json file as a JS object.

Original thread: https://forums.rpgmakerweb.com/threads/passing-json-files-as-command-values.56439/