Tips for writing valid JSON

Methodical approach to finding and avoiding errors in JSON

Teri Radichel
Bugs That Bite

--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

⚙️ Check out my series on Automating Cybersecurity Metrics | Code.

🔒 Related Stories: Bugs | AWS Security | Secure Code

💻 Free Content on Jobs in Cybersecurity | ✉️ Sign up for the Email List

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

JSON can be very tricky to write but here are a few tips:

  1. Test your JSON adding small bits at a time until you find the error.
  2. Write your json like this, step by step, to avoid errors:

Step 1: Add starting and ending curly braces:

{}

Step 2: Add the first element with starting and ending brackets:

{ "Findings": 
[
]
}

Step 3: Add the next set of brackets:

{ "Findings": 
[
{
}
]
}

Step 4: Add your elements — be careful with quotes and commas!

{ "Findings": 
[
{
"Name1": "Value1",
"Name2": "Value2"
}
]
}

Writing your code in this methodical manner will help prevent errors.

--

--

Teri Radichel
Bugs That Bite

CEO 2nd Sight Lab | Penetration Testing & Assessments | AWS Hero | Masters of Infosec & Software Engineering | GSE 240 etc | IANS | SANS Difference Makers Award