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.

Supported languages

Ada, Bash, C, C#, C++, Clojure, Crystal, D, Dart, Elixir, Erlang, F#, Go, Groovy, Haskell, Java, JavaScript, Julia, Kotlin, Lua, MATLAB, Nim, OCaml, Occam-pi, Perl, PHP, PowerShell, Python, R, Ruby, Rust, Scala, Swift, TypeScript, Zig.

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(),
    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.19.tar.gz (296.6 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.19-py3-none-any.whl (64.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: literalizer-2026.3.19.tar.gz
  • Upload date:
  • Size: 296.6 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.19.tar.gz
Algorithm Hash digest
SHA256 0d3faa54faca4a7c65f960ad7c951817f99a02ec9777597da9ba09c34c260b0d
MD5 f302c5dc4eb8c4b7a83e95606b9a7500
BLAKE2b-256 5c9771d2af57161d96c97943f55851b50511d78582506832b8bab1724f3b4c1e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for literalizer-2026.3.19-py3-none-any.whl
Algorithm Hash digest
SHA256 37b64446968003041f482310e8a61245bd7ee580464a4cb7bd8a5ad7bdec3d7e
MD5 03c0f24b3e16de5081fd1cae719c6538
BLAKE2b-256 bd50cec47d3362035e698787c505c82208931dfdd8f85245fd152f493b16b975

See more details on using hashes here.

Provenance

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