Each section is indented a certain amount and has a parent section. For example:
This is called ‘nesting’, and each actual accessory or platform will be nested under their respective parent (Accessories or Platforms). I know it’s confusing because an accessory is called ‘accessory’, and its nested under ‘Accessories’, but hopefully the visual representation of nesting helps.
When you’re configuring your JSON file, you’ll most likely be adding parts to the accessories and platforms sections (yellow and orange, respectively). Here’s what you need to know about proper configuration (using Platforms as an example):
We have two platforms in our config.json file, Hue (green) and Lifx (purple). The Hue platform is above Lifx. Notice at the end of the Hue array, there is a comma after the closed curly bracket?
This tells the system that there’s another array within the Platforms section. Notice that there is no comma after the Lifx platform section? This is because there is no other array for the Platforms section, so the system knows to stop looking for another platform.
Remember, you will only have one Accessories and Platform sections. You can have different accessories and platforms (just like in the example file) within each of these sections, but if you have Platforms or Accessories more than once, you’ll get an error.
A tip with JSON files and homebridge is your best to try figuring it out yourself. It may seem daunting at first, but once you learn correct syntax, you’ll be able to add more complex structures to your config files, allowing for simply amazing homebridge installs. I hope this write up helps!
A Last thing is to check the correct syntax by copy and paste your configfile to https://jsonlint.com
JSONlint.com, checks if all arrays are closed correctly.
Credit: original posted on Reddit by u/nichoaus