loading

Common JSON Errors| Hitchhikers Platform

What You’ll Learn

In this section, you will learn:

  • Common issues to be aware of when working with JSON
  • Examples of good and bad formatting

Common Syntax Errors

Missing quotation marks - Every key and value typically needs to be contained in quotation marks, unless you are specifying a value of type number or literal.

Good formatting:

{
 "key1": "value1",
 "key2": "value2",
 "key3Literal": true,
 "key4Number": 100,
 "key5": "15px"
} 

Bad formatting:

{
 key1: "value1", // key does not have quotations
 "key2": textvalue, // value does not have quotations
 "key3Literal": "true", // literal should not have quotations
 "key4Number": "100" // number should not have quotations
 "key5": 15px //needs quotations as this is not only a number
} 

Missing commas - All key/value pairs must be separated by commas. Do not put a comma after the last item in an array or object.

Good formatting:

{
 "key1": "value1",
 "key2": "value2",
 "key3Literal": true,
 "key4Number": 100
} 

Bad formatting - Missing Commas:

{
 key1: "value1"
 "key2": textvalue
 "key3Literal": "true"
 "key4Number": "100"
} 

Bad formatting - Trailing Comma:

{
 key1: "value1",
 "key2": textvalue,
 "key3Literal": "true",
 "key4Number": "100",
} 

Unclosed Dictionaries and Arrays - Make sure you have closing curly brackets { } and square brackets [ ] for your dictionaries and arrays.

Incorrect Casing - JSON keys are case sensitive, so make sure to match the expected casing of your keys when interacting with JSON files.

A really helpful tool to validate your JSON is called JSONLint.

unit Quiz
+20 points
Daily Quiz Streak Daily Quiz Streak: 0
Quiz Accuracy Streak Quiz Accuracy Streak: 0
    Error Success Question 1 of 2

    What is wrong with the JSON below? (Select all that apply)

    {
      color: "red"
      display: true
    }
    Error Success Question 2 of 2

    What is wrong with the JSON below? (Select all that apply)

    {
      "type": "faq",
      "name": "Frequently Asked Questions", 
      "isExpandable": "false",
    }

    Wahoo - you did it! 🙌

    You've already completed this quiz, so you can't earn more points.You completed this quiz in 1 attempt and earned 0 points! Feel free to review your answers and move on when you're ready.
1st attempt
0 incorrect
Splash Loading