Skip to content

Commit e9f811d

Browse files
committed
feat: add CITATION.cff, CODE_OF_CONDUCT.md, and CONTRIBUTING.md; update README with citation info; implement GitHub Actions for testing
1 parent 7ba5155 commit e9f811d

11 files changed

Lines changed: 259 additions & 137 deletions

File tree

.github/workflows/tests.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
test:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
python-version: ["3.9", "3.10", "3.11", "3.12"]
13+
steps:
14+
- uses: actions/checkout@v4
15+
- uses: actions/setup-python@v5
16+
with:
17+
python-version: ${{ matrix.python-version }}
18+
- name: Install dependencies
19+
run: |
20+
python -m pip install --upgrade pip
21+
pip install -e .
22+
pip install -r requirements-dev.txt
23+
- name: Run tests
24+
run: pytest -q

CITATION.cff

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
cff-version: 1.2.0
2+
title: partialjson
3+
message: "If you use this software, please cite it as below."
4+
type: software
5+
authors:
6+
- family-names: Akbarzadeh
7+
given-names: Nima
8+
orcid: "https://orcid.org/0009-0005-8143-8083"
9+
repository-code: "https://github.com/iw4p/partialjson"
10+
keywords: [python, json, parsing, streaming]
11+
version: 1.0.0
12+
date-released: 2025-10-05
13+

CODE_OF_CONDUCT.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Code of Conduct
2+
3+
We are committed to a welcoming and inclusive community. We expect all contributors and users to be respectful and constructive.
4+
5+
- Be kind and professional.
6+
- Assume good intent; seek to understand before responding.
7+
- No harassment, discrimination, or personal attacks.
8+
9+
Violations may be reported confidentially to the maintainer at iw4p@protonmail.com. We will take appropriate action.

CONTRIBUTING.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Contributing to partialjson
2+
3+
Thanks for your interest in contributing! This project welcomes bug reports, feature requests, and pull requests.
4+
5+
## Getting started
6+
7+
- Fork and clone the repository
8+
- Create a virtual environment and install dependencies
9+
- Run tests to ensure a clean baseline
10+
11+
```bash
12+
python -m venv .venv
13+
source .venv/bin/activate
14+
pip install -e .
15+
pip install -r requirements-dev.txt
16+
pytest -q
17+
```
18+
19+
## Development workflow
20+
21+
- Create a feature branch from `main`
22+
- Add tests for new behavior
23+
- Run `pytest` locally and ensure all tests pass
24+
- Submit a pull request with a clear description and motivation
25+
26+
## Code style
27+
28+
- Prefer small, readable functions and clear naming
29+
- Add focused docstrings where non-obvious decisions are made
30+
- Keep public API changes minimal and documented in `CHANGELOG.md`
31+
32+
## Reporting issues
33+
34+
Please include:
35+
36+
- Expected behavior and what happened instead
37+
- Minimal reproducible example
38+
- Environment details (Python version, OS)
39+
40+
Thank you for helping improve partialjson!

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,18 @@ Also can be found on [pypi](https://pypi.org/project/partialjson/)
4747
- Install the package by pip package manager.
4848
- After installing, you can use it and call the library.
4949

50+
## Testing
51+
52+
```bash
53+
pip install -e .
54+
pip install -r requirements-dev.txt
55+
pytest -q
56+
```
57+
58+
## Citation
59+
60+
If you use this software, please cite it using the metadata in `CITATION.cff`.
61+
5062
## Star History
5163

5264
[![Star History Chart](https://api.star-history.com/svg?repos=iw4p/partialjson&type=Date)](https://star-history.com/#iw4p/partialjson&Date)

paper/paper.bib

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
@misc{rfc8259,
2+
title = {The {JavaScript} Object Notation ({JSON}) Data Interchange Format},
3+
author = {Bray, Tim},
4+
howpublished = {RFC 8259},
5+
year = {2017},
6+
doi = {10.17487/RFC8259}
7+
}
8+
9+
@inproceedings{ijson,
10+
title = {ijson: Iterative JSON parser for Python},
11+
author = {Iglesias, Ivan},
12+
year = {2014},
13+
url = {https://pypi.org/project/ijson/}
14+
}
15+
16+
@misc{python-json,
17+
title = {json — JSON encoder and decoder},
18+
author = {{Python Software Foundation}},
19+
year = {2024},
20+
url = {https://docs.python.org/3/library/json.html}
21+
}
22+

paper/paper.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
---
2+
title: "partialjson: Parsing incomplete JSON streams safely in Python"
3+
tags:
4+
- Python
5+
- JSON
6+
- streaming
7+
- parsing
8+
- LLM
9+
- OpenAI
10+
authors:
11+
- name: Nima Akbarzadeh
12+
orcid: 0009-0005-8143-8083
13+
affiliation: 1
14+
affiliations:
15+
- name: Independent Researcher
16+
index: 1
17+
date: 2025-10-05
18+
bibliography: paper.bib
19+
---
20+
21+
# Summary
22+
23+
partialjson is a small Python library for extracting useful data from partial or incomplete JSON inputs, such as streaming responses from Large Language Models (LLMs) and truncated payloads. It is commonly used to parse the output of models from providers like OpenAI. The library recovers as much structure as possible while remaining faithful to JSON semantics, helping researchers and practitioners work with unreliable or progressive sources (e.g., HTTP chunked transfer, LLM token streams, and log tails).
24+
25+
# Statement of need
26+
27+
Many data-centric research workflows increasingly consume JSON incrementally. A prominent use case is parsing streaming responses from LLMs, which often output JSON token by token but may be interrupted or malformed. Standard parsers reject these incomplete buffers, forcing researchers to build ad-hoc workarounds like buffering, regexes, or fragile state machines to repair the invalid JSON. partialjson provides a focused, lightweight solution: it parses arrays, objects, strings, numbers, booleans, and nulls from incomplete inputs and returns the maximal valid prefix. This enables early inspection, progress reporting, and robust ingestion pipelines for LLM outputs without bespoke parser code.
28+
29+
# Functionality
30+
31+
partialjson exposes a simple factory‑style API to parse any incoming buffer and return Python data structures. It supports a strict mode for standards‑compliant behavior and a relaxed mode for pragmatic recovery of incomplete strings or numbers. Typical usage requires only a few lines of code and integrates with stream readers or callback loops. The library is pure‑Python with no runtime dependencies and works across supported CPython versions.
32+
33+
Key features:
34+
35+
- Parse incomplete objects and arrays, recovering maximal valid structure
36+
- Handle strings, numbers, booleans, and nulls with optional relaxed handling
37+
- Report remaining unparsed tail for resumed parsing
38+
- Minimal API and small footprint
39+
40+
See the project README for installation and examples.
41+
42+
# Acknowledgements
43+
44+
We thank open‑source JSON tooling and prior libraries that inspired streaming‑oriented parsing approaches.
45+
46+
# References

partialjson/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from .json_parser import JSONParser
88

9-
__version__ = "0.1.0"
9+
__version__ = "1.0.0"
1010
__author__ = "Nima Akbarzadeh"
1111
__author_email__ = "iw4p@protonmail.com"
1212
__license__ = "MIT"

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pytest>=7.0

test.py

Lines changed: 0 additions & 136 deletions
This file was deleted.

0 commit comments

Comments
 (0)