JSON → Anything converters (Python) — small, dependency-free helpers.
Project description
json_to_anything
Python implementations of the JSON → Anything converters. Dependency-free helpers to convert simple JSON-like objects (dicts/lists) into CSV, YAML-like text, language-specific class definitions, SQL inserts, and more.
Highlights:
- Package name:
json_to_anything(seepip/setup.py) - License: MIT (see
../LICENSE)
Install (local)
From the project root, you can install locally into your environment:
cd pip
pip install .
Add metadata to setup.py (author, description, long_description, classifiers, python_requires, etc.) before publishing.
Quick usage
from json_any_endproduct import to_csv, to_yaml
data = [{"id":1, "name":"Alice"}, {"id":2, "name":"Bob"}]
print(to_csv(data))
print(to_yaml(data))
CLI usage
The package includes a lightweight cli() function in json_any_endproduct.__init__ which reads JSON from stdin and prints a conversion result. Example (default converter is to_csv):
echo '[{"a":1, "b":2}]' | python -c "from json_any_endproduct import cli; cli()"
# or explicitly specify function
echo '[{"a":1}]' | python -c "from json_any_endproduct import cli; import sys; sys.argv=['', 'to_yaml']; cli()"
To install a convenient command-line entry point, add to setup.py:
setup(
name='json_any_endproduct',
...,
entry_points={
'console_scripts': [
'json-any=json_any_endproduct:cli'
]
}
)
After installing, you can run:
echo '[{"a":1}]' | json-any to_csv
API (selected functions)
- to_yaml — simple YAML-like serializer
- to_csv — CSV generator (headers from keys)
- to_typescript — generates a TypeScript interface from an example object
- to_js — pretty JSON (indentation)
- to_schema_summary — key:type summary
- to_html_table — basic HTML table
- to_query / to_form_urlencoded — URL/query encoders
- to_markdown_table — Markdown table
- to_plantuml / to_mermaid — diagram skeletons
- to_sql_insert / to_bash_export / to_csharp / to_java / to_python_dataclass / to_go_struct / to_rust_struct / to_dart_class / to_php_array / to_proto — language/format outputs
See pip/json_any_endproduct/__init__.py for the full implementations and limitations (these are intentionally small and naive implementations for quick conversions and prototyping).
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file json_to_anything-1.0.2.tar.gz.
File metadata
- Download URL: json_to_anything-1.0.2.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12e87314e3a37431b1553d6be3bac6d092a2a7795aa82bf56cf86d3c9316c608
|
|
| MD5 |
b13817c20ec9f8d2040fbe27d954e4dd
|
|
| BLAKE2b-256 |
0c28ed62baf1f583b27c4bef158e419e586c3d8b83b11596c17b7e5695a6805c
|
File details
Details for the file json_to_anything-1.0.2-py3-none-any.whl.
File metadata
- Download URL: json_to_anything-1.0.2-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
efc78a2d4d1697e9e85756556307903217ee07fbdb98596420366a52460bb73c
|
|
| MD5 |
ff26e4da079074e79523764d3cdf5ba6
|
|
| BLAKE2b-256 |
1f10d917f25c640ae601ced8c62077d3fe012532346ef75cdd80ae907116cfab
|