On this page
  1. json.JSONDecodeError
  2. Import
  3. Signature & Overview
  4. Methods & Attributes
  5. Usage
  6. Gotchas
  7. REPL Inspect

json.JSONDecodeError

Prev: json.dumps | Up: json | Next: json.JSONDecoder
Rel: json.dump, json.dumps, json.JSONDecoder, json.JSONEncoder
Ref: docs.python.org โ€” json.JSONDecodeError
Tags: #public #python3 #stdlib #json


Import

import json
from json import JSONDecodeError

Signature & Overview

json.JSONDecodeError(msg, doc, pos)

Subclass of ValueError with the following additional properties: msg: The unformatted error message doc: The JSON document being parsed

Methods & Attributes

Usage

import json

try:
    json.loads('{"a": 1,}')
except json.JSONDecodeError as exc:
    assert exc.lineno == 1
    assert exc.colno == 9
    assert "property name" in exc.msg

Gotchas

REPL Inspect

from json import JSONDecodeError
help(JSONDecodeError)

Linked from

Related notes