Skip to main content

Simple json printer for python

Project description

jprint2

A drop-in replacement for print that formats output as JSON using jsons and colorizes it with pygments.

Example

Usage

>>> from jprint2 import jprint
>>> jprint("a", "b", "c")
[
  "a",
  "b",
  "c"
]
>>> jprint({"name": "Mark", "mood": 10})
{
  "name": "Mark",
  "mood": 10
}
>>> jprint("Mark")
Mark
>>> jprint('{"name": "Mark"}')
{
  "name": "Mark"
}
>>> import jprint2.replace_print_with_jprint  # replace built-in print
>>> print("Hello", "friend!")
[
  "Hello",
  "friend!"
]
>>> from jprint2 import set_defaults  # configure defaults
>>> set_defaults(indent=2, sort_keys=True)
>>> from jprint2 import jformat  # format JSON to string
>>> my_json_string = jformat({"name": "Mark", "age": 30})

License

MIT License

Author

Mark Lidenberg marklidenberg@gmail.com

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

jprint2-0.1.2.tar.gz (42.2 kB view details)

Uploaded Source

Built Distribution

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

jprint2-0.1.2-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file jprint2-0.1.2.tar.gz.

File metadata

  • Download URL: jprint2-0.1.2.tar.gz
  • Upload date:
  • Size: 42.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.2

File hashes

Hashes for jprint2-0.1.2.tar.gz
Algorithm Hash digest
SHA256 8b6cf73f478e25f2cddeb5f0d3685371884f5202677c2c9f2dbae387a3ba0cf8
MD5 2df53c5fa21af8af26082002c94333ee
BLAKE2b-256 1dea5df444a429cc8f268e06625f76919f8ff022cbd84dd23e0923339fe94d31

See more details on using hashes here.

File details

Details for the file jprint2-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: jprint2-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.2

File hashes

Hashes for jprint2-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c38d1f6dd88df079ff07e11fb5cf9463a2c80561a3fb8391532269d61b6599c4
MD5 bd35d60a2f3c5b9c85c89ca990a7d4fc
BLAKE2b-256 1265fe799a425a16861aaf964761013ca10079a7d9422ac38fa5aa4d0b734482

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