Metadata-Version: 2.4
Name: parsebox
Version: 0.2.0
Summary: Common utils for web apps: safe parsing helpers and nested json access
Home-page: https://github.com/shashankkr9/parsebox
Author: Shashank Kumar
Author-email: me@shashankkumar.com
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
License-File: LICENSE

# Parsebox

> Common set of utilities when building a web app

[![PyPI Version][pypi-image]][pypi-url]

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

```shell
pip install parsebox
```

## Usage

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

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

```python
>>> 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`

<!-- Badges -->

[pypi-image]: https://img.shields.io/pypi/v/parsebox
[pypi-url]: https://pypi.org/project/parsebox/

