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(),
    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.18.tar.gz (214.1 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.18-py3-none-any.whl (61.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: literalizer-2026.3.18.tar.gz
  • Upload date:
  • Size: 214.1 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.18.tar.gz
Algorithm Hash digest
SHA256 06ec098c8a31ed6143d69b14a1a45c1e6c81f9a4c3aa367230c274fe08541a24
MD5 deb78d2eb702cd0c83975e04b03b8f14
BLAKE2b-256 40a489bef7aee65fa8c63cffe723cf32e72333bcc0189f14b8a6994fe5ef2a3b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for literalizer-2026.3.18-py3-none-any.whl
Algorithm Hash digest
SHA256 4565b07f7a4b32556255e336736991d8555f4e48de792812a70174398b7ff3bb
MD5 38730888c5b22a8a437f93f76a83a230
BLAKE2b-256 7078b04d33d2caaf628dc446cce7930eb5ac6d80906accb32ed9d0afd16fc887

See more details on using hashes here.

Provenance

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