Metadata-Version: 2.1
Name: json-streams
Version: 0.1.1
Summary: Stream objects from json-arrays or json lines lazily..
Home-page: https://github.com/spraakbanken/json-streams-py
Author: Språkbanken at the University of Gothenburg
Author-email: sb-info@svenska.gu.se
Maintainer: Språkbanken
Maintainer-email: sb-info@svenska.gu.se
License: MIT
Project-URL: Bug Tracker, https://github.com/spraakbanken/json-streams-pu/issues
Project-URL: Documentation, https://github.com/spraakbanken/json-streams-py
Project-URL: Source Code, https://github.com/spraakbanken/json-streams-py
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: Unix
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Utilities
Description-Content-Type: text/markdown
Requires-Dist: ijson
Provides-Extra: dev
Requires-Dist: pytest ; extra == 'dev'
Requires-Dist: pytest-cov ; extra == 'dev'
Requires-Dist: flake8 ; extra == 'dev'
Requires-Dist: black ; extra == 'dev'
Requires-Dist: isort ; extra == 'dev'
Requires-Dist: reno ; extra == 'dev'
Requires-Dist: pylint ; extra == 'dev'

# json-streams



[![Build Status](https://travis-ci.org/spraakbanken/json-streams-py.svg?branch=master)](https://travis-ci.org/spraakbanken/python-json-tools)
[![codecov](https://codecov.io/gh/spraakbanken/json-streams-py/branch/master/graph/badge.svg)](https://codecov.io/gh/spraakbanken/python-json-tools)
[![Build Status](https://github.com/spraakbanken/json-streams-py/workflows/Build/badge.svg)](https://github.com/spraakbanken/python-json-tools/actions)
[![PyPI status](https://badge.fury.io/py/json-streams.svg)](https://pypi.org/project/json-streams/)

Tools for working with json (especially) json-arrays.

Uses `ujson` if present, otherwise standard `json`.

## Usage

### Installation
```
pip install json-streams
```
### json-iter (`lib: sb_json_tools.jt_iter`)

Allows you to use `json.load` and `json.dump` with
both json and json-lines files as well as dumping generators.

```
from sb_json_tools import jt_iter

# This command tries to guess format and opens the file
data = jt_iter.load_from_file("data.json") # or data.jsonl

# Write to file, again guessing format
jt_iter.dump_to_file(data, "data.jsonl")
```

```
from sb_json_tools import json_iter, jsonl_iter

# Open and read the file
data = json_iter.load_from_file("data.json")

# Process file

# Write to file
jsonl_iter.dump_to_file(data, "data.jsonl")
```

# Development

After cloning the repo, just run
```
$ make test
```
to setup a virtual environment,
install dev dependencies
and run the unit tests.

*Note:* If you run the command in a activated virtual environment,
that environment is used instead.



