Skip to main content

Convert JSON data structures to native language literal syntax.

Project description

Build Status PyPI

literalizer

literalizer converts JSON data structures to native language literal syntax (Python, JavaScript, TypeScript, Go, Ruby, C#, C++, Java, Kotlin, Rust, Haskell, Swift, PHP).

Installation

Requires Python 3.12+.

pip install literalizer

Usage

"""Example of using literalizer."""

from literalizer import literalize_yaml
from literalizer.languages import GO

# YAML comments are preserved using the target language's comment syntax
yaml_config = """\
# Server configuration
host: localhost  # default host
port: 8080
# Enable debug mode for development
debug: true
"""
result = literalize_yaml(
    yaml_string=yaml_config,
    language=GO,
    prefix="    ",
    wrap=True,
)
# result:
# map[string]any{
#     // Server configuration
#     "host": "localhost",  // default host
#     "port": 8080,
#     // Enable debug mode for development
#     "debug": true,
# }

Use cases

  • Generate test fixtures from JSON samples.

  • Convert API responses to language-native data structures for documentation.

  • Create type-safe literal data from JSON config files.

Full documentation

See the full documentation for more information including how to contribute.

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

literalizer-2026.3.17.1.tar.gz (70.4 kB view details)

Uploaded Source

Built Distribution

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

literalizer-2026.3.17.1-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file literalizer-2026.3.17.1.tar.gz.

File metadata

  • Download URL: literalizer-2026.3.17.1.tar.gz
  • Upload date:
  • Size: 70.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for literalizer-2026.3.17.1.tar.gz
Algorithm Hash digest
SHA256 db4b4380cc6cf5657988446741f3dfd02d0f0e1bca6e32d1091c16c822296734
MD5 ef557864a2efca26009e81e9b5960064
BLAKE2b-256 922b8a7763ccfb280614f4db3e645032652b78cbaa33f9d6d055c3a6c39604c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for literalizer-2026.3.17.1.tar.gz:

Publisher: release.yml on adamtheturtle/literalizer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file literalizer-2026.3.17.1-py3-none-any.whl.

File metadata

File hashes

Hashes for literalizer-2026.3.17.1-py3-none-any.whl
Algorithm Hash digest
SHA256 44e36ab7734af5d72fa6601903728098fdf49907faed9c7f62f2fb7497403b75
MD5 09bd7e0bc1a6b27c8589ca78b58f1e4a
BLAKE2b-256 bacb4c54b6b9627679127ffe2aea6b8ef7a977d8f2a2dd5098a3e4cfbfd042be

See more details on using hashes here.

Provenance

The following attestation bundles were made for literalizer-2026.3.17.1-py3-none-any.whl:

Publisher: release.yml on adamtheturtle/literalizer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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