Skip to content

PRS002 - Invalid JSON

Description

The input is not valid JSON. This error occurs when the JSON parser encounters syntax errors in the document.

Severity

Error

When This Occurs

  • JSON contains syntax errors (missing commas, brackets, quotes)
  • File contains non-JSON content
  • Encoding issues in the file

Example

JSON
{
  "name": "Product"
  "description": "Missing comma above"
}

Common Causes

  1. Missing commas between properties
  2. Trailing commas (not allowed in JSON)
  3. Single quotes instead of double quotes
  4. Unquoted property names
  5. Comments in JSON (not allowed)

Resolution

  1. Validate JSON syntax:
Bash
python -m json.tool document.json
  1. Use a JSON linter:
Bash
jq . document.json
  1. Check encoding (should be UTF-8):
Python
with open("document.json", "r", encoding="utf-8") as f:
    data = json.load(f)