Skip to main content

This is a standalone version of the JSON parser used in pydantic-core. The recommendation is to only use this package directly if you do not use pydantic.

Project description

This project is a branch of jiter on QPython.

This is a standalone version of the JSON parser used in pydantic-core. The recommendation is to only use this package directly if you do not use pydantic.

Examples

The main function provided by Jiter is from_json(), which accepts a bytes object containing JSON and returns a Python dictionary, list or other value.

from jiter import from_json

json_data = b'{"name": "John", "age": 30}'
parsed_data = jiter.from_json(json_data)
print(parsed_data)  # Output: {'name': 'John', 'age': 30}

Handling Partial JSON

Incomplete JSON objects can be parsed using the partial_mode= parameter.

import jiter

partial_json = b'{"name": "John", "age": 30, "city": "New Yor'

# Raise error on incomplete JSON
try:
    jiter.from_json(partial_json, partial_mode=False)
except ValueError as e:
    print(f"Error: {e}")

# Parse incomplete JSON, discarding incomplete last field
result = jiter.from_json(partial_json, partial_mode=True)
print(result)  # Output: {'name': 'John', 'age': 30}

# Parse incomplete JSON, including incomplete last field
result = jiter.from_json(partial_json, partial_mode='trailing-strings')
print(result)  # Output: {'name': 'John', 'age': 30, 'city': 'New Yor'}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

jiter_qpython-0.7.0.tar.gz (360.7 kB view details)

Uploaded Source

Built Distribution

jiter_qpython-0.7.0-py3-none-any.whl (360.5 kB view details)

Uploaded Python 3

File details

Details for the file jiter_qpython-0.7.0.tar.gz.

File metadata

  • Download URL: jiter_qpython-0.7.0.tar.gz
  • Upload date:
  • Size: 360.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.7

File hashes

Hashes for jiter_qpython-0.7.0.tar.gz
Algorithm Hash digest
SHA256 456e9fd0838dd20f6f0ac5aa4a01a7be95048ba0885026ba7001eb135e8c350e
MD5 5ee75abdcb2caacf16940285f6f1ad24
BLAKE2b-256 b40442b08d46cb4979cd7315df7e21671a8db5e202419b9c19b3c21ffc2fca1b

See more details on using hashes here.

File details

Details for the file jiter_qpython-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: jiter_qpython-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 360.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.7

File hashes

Hashes for jiter_qpython-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5aceb00f128d5d4bb64e9487fa8f7c7678a395602306a5c100bf1080fcc64100
MD5 1a70bb5f2178d69ac189fa58f21e341f
BLAKE2b-256 4a2bccf518a8e8805367dfd3e7d390a5618ee66688234ae3e7b9d4ce1078cd39

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page