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

json.JSONDecoder

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


Import

import json
from json import JSONDecoder

Signature & Overview

json.JSONDecoder(*, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, strict=True, object_pairs_hook=None)

Simple JSON https://json.org decoder Performs the following translations in decoding by default: +---------------+-------------------+

Methods & Attributes

Usage

import json

# raw_decode() parses one JSON value from a buffer and returns (value, next_index)
decoder = json.JSONDecoder()
buf = '{"a": 1} {"b": 2}'
first, idx = decoder.raw_decode(buf)
second, _ = decoder.raw_decode(buf, idx + 1)

assert first == {"a": 1} and second == {"b": 2}

Gotchas

REPL Inspect

from json import JSONDecoder
help(JSONDecoder)

Linked from

Related notes