New Configuration Files in JSON

A quick primer on editing a JSON file for configurations instead of PHP array values.

If it looked like this in PHP arrays (the old style):

$Configuration['A']['Z'] = 'Hello';
$Configuration['A']['B']['C'] = 'Value';
$Configuration['A']['B']['D'] = 'Value1';
$Configuration['A']['B']['E'] = 'Value2';

Would now look like this:

"A": {
   "Z": "Hello",
   "B": {
      "C": "Value",
      "D": "Value1",
      "E": "Value2"
   }
}

A few things to call out:

  • Items get grouped at each tier with curly braces
  • Lists of parellel items get commas between them
  • All non-integer, non-boolean (true/false) values must be wrapped in double quotes

The new editor will warn you about syntax errors.

Also, be warned that you must click inside the config and use it's built-in search in the top corner (cmd+f) to search in the config. The broader browser find may not work.

Comments