So I have this strong of JSON:
{
"default": [
{
"name": "Default",
"access": "user",
"temp": false
}
],
"en": [
{
"name": "English",
"access": "user",
"temp": false
}
],
"dead": [
{
"name": "Dead",
"access": "user",
"temp": false
}
],
"es": [
{
"name": "EspaƱol",
"access": "user",
"temp": false
}
],
"admin": [
{
"name": "Admins",
"access": "operator",
"temp": false
}
]
}
Which I then have converted into a table using
util.JSONToTable. I don't have the ability to test it right now (I can in a few hours but not at the moment -- I'll edit this if I can test before someone responds), but how does this _exactly_ work in this case. On the wiki page, it says
WARNING
This function converts keys to numbers whenever possible
How would this affect my table? I need to access these tables like "SCC.Channels[ "default" ]" or something like that, but if the command assigns numeric keys, I could access it like "SCC.Channels[ 1 ].name" or something.
Like I said I can test this myself in a couple hours but I can't right now (at school). Is there anyone who knows this for sure?
EDIT: Ran it myself:
lua_run tab = util.JSONToTable( '{ "default": [ { "name": "Default", "access": "user", "temp": false } ], "en": [ { "name": "English", "access": "user", "temp": false } ] }') PrintTable( tab )and this is the output:
default:
1:
access = user
name = Default
temp = false
en:
1:
access = user
name = English
temp = false
But I'm having a bit of trouble understanding it, what is the "1:" doing under the "en:" and "default:"? Does that mean it would need to be SCC.Channels[ "default" ][ 1 ].name?
From what I understand, table structure would look like this:
SCC.Channels = {
"default" = {
[1] = {
"access" = "user",
"name" = "Default",
"temp" = false
}
}
}
Am I correct?
I've never used this tool before so if someone could help me understand, that'd be appreciated.
EDIT2: Now that I think about it, I could use "ULib.parseKeyValues" and "ULib.makeKeyValues" as my addon does (for now, at least) rely on ULib. But I'd still like to understand this as I do want it to be standalone.