Skip to main content

Streaming JSON to Markdown converter

Project description

jmd - JSON to Markdown

Streaming JSON to Markdown converter using blockquote syntax.

Installation

pip install jmd

Usage

CLI

# Pipe JSON
cat data.json | jmd

# JSONL
cat records.jsonl | jmd

# With head (streaming)
cat huge.json | jmd | head -20

Python API

from jmd import to_markdown, to_markdown_from_str, stream_json_to_md

# From Python object
md = to_markdown({"name": "Alice", "items": [1, 2, 3]})

# From JSON string
md = to_markdown_from_str('{"key": "value"}')

# Streaming from file
with open("data.json") as f:
    for line in stream_json_to_md(f):
        print(line)

Format

JSON Markdown
{"key": "value"} > key: value
{"key": "has: colon"} > key: + > > has: colon
{"# list": [...]} > # list: + items
{"bad key": v} > <q>bad key</q>: v
[], {}, "" [], {}, "" (inline)
Array items Separated by >
Multiline strings depth+1, no separator

Example

{"name": "Gilbert", "wins": [["straight\nwin", "7♣"], {"Test": ["8"]}]}
> name: Gilbert  
> # wins:  
> > > > straight  
> > > > win  
>  
> > > 7♣  
>  
> > > # Test:  
> > > > > 8  

Features

  • Streaming: O(chunk + max_string + depth) memory
  • C-accelerated: Uses json.decoder.scanstring
  • JSONL support: Multiple JSON values
  • Pipe-friendly: Handles | head gracefully

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

jmd-0.1.0.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

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

jmd-0.1.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file jmd-0.1.0.tar.gz.

File metadata

  • Download URL: jmd-0.1.0.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for jmd-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9009321bb5d5c3012ec9bd74fb72d664448243a63149b9215dd7ce20f1eefc2d
MD5 048c36fb5f24a1c7c1e4b78e50f57f5b
BLAKE2b-256 6799cb2ab81563aa28e31029933e7cc59e4bbfa4dfa6461c0efcc8c7a42fbb6e

See more details on using hashes here.

File details

Details for the file jmd-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: jmd-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for jmd-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6e3724e88e4921325a646e0d9471ac53e0b411dcba05bfa5dcedb3bbe674d359
MD5 d74469e786568239eec6336c4762da69
BLAKE2b-256 06067c1634e0a448c0153153d76a3f8840b232819b8a7855ee8eed6e7b95f131

See more details on using hashes here.

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