Skip to main content

Common utils for web apps: safe parsing helpers and nested json access

Project description

Parsebox

Common set of utilities when building a web app

PyPI Version

Formerly published as owlutils; also absorbs the json-parser-utils package.

Parsing functions:

  • safeint
  • safeintorzero
  • safeintorbignumber
  • safefloat
  • jsonb_date_to_str
  • pretty_json
  • onewhite
  • join_strings_if_not_null
  • get_full_name
  • get_exception_traceback

Nested json access:

  • JsonParser

Installation

pip install parsebox

Usage

>>> from parsebox import parsing
>>> parsing.safeint("123")
123

Access nested json with dot-separated paths (array indices are plain numbers):

>>> from parsebox import JsonParser
>>> data = {"person": {"name": "John", "kids": [{"name": "Lorem"}]}}
>>> JsonParser(data).access("person.kids.0.name").value
'Lorem'
>>> JsonParser(data).access("person.address.city").value  # missing keys return None

Migrating from owlutils / json-parser-utils

  • from owlutils import parsingfrom parsebox import parsing (same functions)
  • from json_parser_utils import JsonParserfrom parsebox import JsonParser (same API)
  • json_parser_utils.utils.safe_intparsebox.parsing.safeint

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

parsebox-0.2.0.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

parsebox-0.2.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file parsebox-0.2.0.tar.gz.

File metadata

  • Download URL: parsebox-0.2.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.2

File hashes

Hashes for parsebox-0.2.0.tar.gz
Algorithm Hash digest
SHA256 998dca1c2cb8da1a577f8508d4d802817be8d254a340d35ed83c9e5f25c7523b
MD5 c46a500f2cc604310b9cb61f857ea23b
BLAKE2b-256 32b653c49d25415e67ffcea18ee058e1f083520ac9762f42d24be3277b659b50

See more details on using hashes here.

File details

Details for the file parsebox-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: parsebox-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.2

File hashes

Hashes for parsebox-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4e9b1d2baedc047eaf7d8f316f587f17e2daab9d4aa5488077afa5c1c2f5cfa1
MD5 12da1e6daffbe4e10dc7bf4bb7a514eb
BLAKE2b-256 767e161f576ea29d88b879cd1aa3e9bd770d6815fa8aba05838bb289c903be40

See more details on using hashes here.

Supported by

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