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.tar.gz (64.3 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-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: literalizer-2026.3.17.tar.gz
  • Upload date:
  • Size: 64.3 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.tar.gz
Algorithm Hash digest
SHA256 a2a497b2244c2ab520ba26fe86ce0a085036344d2377cb90d8b3cf8e5f76dc24
MD5 29f1cab6071f5f0329c53bece0cd4753
BLAKE2b-256 8cbc18bf9975c9d8f663025482d236f1effa5ce06ca43a7c7f97b6378df1efb1

See more details on using hashes here.

Provenance

The following attestation bundles were made for literalizer-2026.3.17.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-py3-none-any.whl.

File metadata

File hashes

Hashes for literalizer-2026.3.17-py3-none-any.whl
Algorithm Hash digest
SHA256 7bbee1abd141f14e1fec29a999b6bb4201c246f342d685cad547c5e6cdbdcd71
MD5 0bae0e23bb1e708abf970917480c4318
BLAKE2b-256 c09ff3c0414bf05f3623d914217714eda12155f84a0dc407b3c593193c0a9968

See more details on using hashes here.

Provenance

The following attestation bundles were made for literalizer-2026.3.17-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