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

# From file
jmd data.json

# JSONL
cat records.jsonl | jmd

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

# With key filtering
jq '.items[]' data.json | jmd

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

Unstable, subject to change.

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: jmd-0.1.1.tar.gz
  • Upload date:
  • Size: 4.8 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.1.tar.gz
Algorithm Hash digest
SHA256 650ee81345b644a9197d85939e49992f2fa2f133744aab4557aa7f736db9f66e
MD5 9fc9e8d3ebf2a7e99b7f8f11089e86c1
BLAKE2b-256 509c773833cb134c4e4f9b0ca47e0e6be4c5d904a58933b228d010c5a3502ce5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: jmd-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.3 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3af6652ed898f7c7861c707277e78ec0f46f8a2f5590b9ea472ce94e9f5d9cfb
MD5 e10a26d860c83b1585b8fefc50155e30
BLAKE2b-256 65eaf863267161f9daf3a6a2af3bec4678d267e1626aba9b945201932af10608

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