Common utils for web apps: safe parsing helpers and nested json access
Project description
Parsebox
Common set of utilities when building a web app
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 parsing→from parsebox import parsing(same functions)from json_parser_utils import JsonParser→from parsebox import JsonParser(same API)json_parser_utils.utils.safe_int→parsebox.parsing.safeint
Project details
Release history Release notifications | RSS feed
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)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
998dca1c2cb8da1a577f8508d4d802817be8d254a340d35ed83c9e5f25c7523b
|
|
| MD5 |
c46a500f2cc604310b9cb61f857ea23b
|
|
| BLAKE2b-256 |
32b653c49d25415e67ffcea18ee058e1f083520ac9762f42d24be3277b659b50
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e9b1d2baedc047eaf7d8f316f587f17e2daab9d4aa5488077afa5c1c2f5cfa1
|
|
| MD5 |
12da1e6daffbe4e10dc7bf4bb7a514eb
|
|
| BLAKE2b-256 |
767e161f576ea29d88b879cd1aa3e9bd770d6815fa8aba05838bb289c903be40
|