Skip to main content

No project description provided

Project description

json_to_anything

PyPI version license

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 (see pip/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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

json_to_anything-1.0.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

json_to_anything-1.0.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file json_to_anything-1.0.1.tar.gz.

File metadata

  • Download URL: json_to_anything-1.0.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for json_to_anything-1.0.1.tar.gz
Algorithm Hash digest
SHA256 c11248de4d0a17f43a5a3dfe2bcaeecee5ce38db40438a0267518c27002c9480
MD5 dc9258affce2f0276f3ad477341d530d
BLAKE2b-256 dbd2c8f7a4d03bf439bfd4b548fb1e57421cd748ce22c2888f7524e60658b192

See more details on using hashes here.

File details

Details for the file json_to_anything-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for json_to_anything-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a6d8a18c74b1e3b5d4b7a29927e25c92970de1e8206d2397f60e0e58ea1225b8
MD5 5449118d324c77a28ba71343ff5caa5c
BLAKE2b-256 b547a39db68a696757496aa266a65995aa0949338fe0b90fbb88390f8ecf9313

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page