Skip to content

JSON table format

doughphunghus edited this page Sep 1, 2020 · 1 revision

Note about format:

The data structure I am using is basically a table, sometimes containing other tables! I will try to consistently refer to the configuration as "tables", "keys", and "values". I kept this format, even when some configuration data would work better as a list/array, to make it easier to work with.

Here is an example:

{
  "key1":"value1",
  "key2":"value2",
  "Table2": {
    "key1":"value1",
    "key2":"value2"
  },
  "Table3": {
    "key1":"value3",
    "keyX":"value4"
  }
}

In the example above there are 2 "tables". The first table has no name and is simply the beginning and end brackets {}. This is normal for a json configuration. This first table will generally not be referred to by name and is implied you will have this surrounding all your data.

For the first and second table, the data in them is stored in keys and values. "the first table" has 4 keys and each key has a value. "the second table" (Table2) has 2 keys and each key has a value, the same as Table3.

The value for the Table2 key (and Table3 key) is actually another table.

NOTE: Notice how there are not commas after every item! The json parser in the script is strict and if there is a single comma not in the proper place (or missing commas, or extra commas) it will not parse and the script will error and stop. There will be an error message indicating what line of the json is the problem.