Metadata-Version: 2.1
Name: objectify-json
Version: 0.2.8
Summary: Make accessing JSON like data more convenient.
Home-page: https://github.com/weaming/objectify-json
Author: weaming
Author-email: garden.yuen@gmail.com
License: UNKNOWN
Project-URL: Source, https://github.com/weaming/objectify-json
Project-URL: Bug Reports, https://github.com/weaming/objectify-json
Keywords: json
Platform: UNKNOWN
Description-Content-Type: text/markdown

# Objectify JSON

Make accessing JSON like data more convenient.

## Features

* Access dict value via dot `.` (`data.a.b.c`).
* Always return `ObjectifyJSON` type, which holds the data with type of dict, list or any other primitive types.
* Use `x._data` to get the real data.
* Always return `ObjectifyJSON(None)` if doesn't exist.
* An CLI tool named `object` to process JSON data.

## Install

```
pip3 install objectify-json
```

## Example

See `test.py`

## Functions to process data in batch

* The return value is always `ObjectifyJOSN` too!
* The return value of lambda funtions will always be unwrapped to primitive types.
* The `fn_*` functions all accept optional `unwrap` parameter to enable passing the underlying value as primitive types to lambda. Default is False.

### 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`: `map` on the iterator
* `fn_reduce`: `reduce` on the iterator, lambda as the first positional parameter, optional `initializer` parameter will be passed to built-in `reduce`.
* `fn_lambda`: value in-and-out
* `fn_filter`: `filter` on the iterator

### Dict

* `fn_keys`: Return keys as list.
* `fn_values`: Return values as list.
* `fn_items`: Return items as list. Element has the type `tuple`, e.g. `("key", "value")`.
* `fn_include_keys`: Filter dict. Keep the `keys` you give.
* `fn_exclude_keys`: Filter dict. Remove the `keys` you give.
* `fn_filter_by_value`: Filter dict. Filter by the lambda you give, which accept the value of dict item.
* `fn_filter_by_kv`: Filter dict. Filter by the lambda you give, which accept `key` and `value` two variables.
* `fn_update`: Update dict value. The lambda you give accept the origin value and return a new value.
* `fn_items_update`: Update dict value. The lambda you give accept `key` and `value` two variables and return a new value.


### List

* `fn_sort`: Sort the list in place. The lambda you give will be passed as `key` argument to the `sort` method of list.
* `fn_dedup(fn=None, all=True)`: Dedup the elements in list. If `all` if `False`, the duplication will checked by comparing current value between last value, else will compare to all appeared before.


