Objectify JSON
Make accessing JSON like data more convenient.
Features
- Access dict value via dot
.(data.a.b.c). - Always return
ObjectifyJSONtype, which holds the data with type of dict, list or any other primitive types. - Use
x._datato get the real data. - Always return
ObjectifyJSON(None)if doesn't exist. - An CLI tool named
objectto process JSON data.
Install
pip3 install objectify-json
Example
See test.py
Functions to process data in batch
- The return value is always
ObjectifyJOSNtoo! - The return value of lambda funtions will always be unwrapped to primitive types.
- Most of the
fn_*functions accept optionalunwrapparameter to enable passing the underlying value as primitive types to lambda. Default is False. - When used in CLI tool, if it failed getting the property by property name, e.g.
map, it will retry to get function with prefixfn_added to the name. This will simplify writting the CLI command.
Common
Following methods of ObjectifyJOSN accept optional unwrap to unwrap ObjectifyJOSN data to the underlying built-in data, the default value is False.
fn_map(fn, unwrap=False):mapon the iteratorfn_reduce(fn, initializer=None, unwrap=False):reduceon the iterator, lambda as the first positional parameter, optionalinitializerparameter will be passed to built-inreduce.fn_lambda(fn, unwrap=False): value in-and-outfn_filter(fn, unwrap=False):filteron the iterator
Dict
fn_keys(): Return keys as list.fn_values(): Return values as list.fn_items(): Return items as list. Element has the typetuple, e.g.("key", "value").fn_include_keys(keys): Filter dict. Keep thekeysyou give.fn_exclude_keys(keys): Filter dict. Remove thekeysyou give.fn_filter_by_value(fn): Filter dict. Filter by the lambda you give, which accept the value of dict item.fn_filter_by_kv(fn): Filter dict. Filter by the lambda you give, which acceptkeyandvaluetwo variables.fn_update(key, fn, unwrap=False): Update dict value. The lambda you give accept the origin value and return a new value.fn_items_update(fn, unwrap=False): Update dict value. The lambda you give acceptkeyandvaluetwo variables and return a new value.fn_rename(mapping): Update dict key. Themappingis a list of two-elements list.
List
fn_sort(fn): Sort the list in place. The lambda you give will be passed askeyargument to thesortmethod of list.fn_dedup(fn=None, all=True): Dedup the elements in list. IfallifFalse, the duplication will checked by comparing current value between last value, else will compare to all appeared before.
Metadata
Release files for objectify-json 0.2.19
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| objectify_json-0.2.19-py3-none-any.whl | Python 3 | none | any | Details |
Release files / objectify_json-0.2.19-py3-none-any.whl
| Download URL | objectify_json-0.2.19-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
026d5e21008b2a811acc99d783db6abf1cea467ba4339db9cf72240b00202b83
|
|
BLAKE2b-256 checksum How to use checksums |
e65ad5ca097137d9ea3c8be391ad03a8571e1ee39b94da2d9c2629f595da8407
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.13.0 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.1
|
Security for objectify-json 0.2.19
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.