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).

Installation

Requires Python 3.12+.

pip install literalizer

Usage examples

"""Examples of using literalizer."""

from literalizer import convert_json_to_native_literal

# Convert a JSON array to Python tuple literal
data = [True, None, "hi", [1, 2]]
result = convert_json_to_native_literal(
    data=data,
    language="py",
    prefix="",
    wrap=False,
)
# result: '(True, None, "hi", (1, 2)),'

# Convert to JavaScript/TypeScript array
result = convert_json_to_native_literal(
    data=data,
    language="js",
    prefix="    ",
    wrap=True,
)
# result:
# [
#     true,
#     null,
#     "hi",
#     [1, 2],
# ]

# Supported languages: py, js, ts, go, rb, cs, cpp, java, kt

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: literalizer-2026.3.13.tar.gz
  • Upload date:
  • Size: 13.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.13.tar.gz
Algorithm Hash digest
SHA256 217d2c8e1825dabd45c57e8674fdd39b92b350a00de1bb6ab21be51793162b3c
MD5 581b4c9687ffad3ecdefca3754b86fae
BLAKE2b-256 d778ec5bbeb49ba57751c6e7f16a61d28aaa540000165501cd29b02ca396f99e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for literalizer-2026.3.13-py3-none-any.whl
Algorithm Hash digest
SHA256 4cedca3e071daca78635622ef9107f7ca73c3ba390eb1b5c43c4890835067ec8
MD5 f3f641885a083065e7d4f8d333c2d75d
BLAKE2b-256 5d925df953564721d9e4cb273c588543c592b0ed25ac894dd727bdee076b3b6b

See more details on using hashes here.

Provenance

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