Copyright (c) 2016-2018 Fabien Fleutot.
This software is made available under the MIT public license.
(Kind-of) smart JSON formatter.
Every JSON formatter I've found inserts newline + indent at every list item and every object pair. As a result, instead of being unreadable because it's too large (in a single line), the resulting JSON is unreadable because too tall (too many newlines), especially when dealing with formats like GeoJSON where long lists of coordinates are handled.
This formatter works with a page width in mind, by default 80, and tries to optimize screen space usage in both width and height.
Installation
pip install jsview
Usage
jsview.py [-h] [-w WIDTH] [-i INDENT] [-o OUTPUT] [-l] [-u] [-r] filename
Format JSON inputs with smart line-returns and indendation.
positional arguments:
filename Input file; use '-' to read from stdin
optional arguments:
-h, --help show this help message and exit
-w WIDTH, --width WIDTH
Set the ideal width of the output text; if unspecified,
try to fit the terminal's width as returned by stty.
-i INDENT, --indent INDENT
Indentation, in number of space characters; default=2
-o OUTPUT, --output OUTPUT
Output file; defaults to stdout
-l, --close-on-same-line
When set, further lines are saved by closing lists and
objects on the same line as the last element.
-u, --utf8-output Output strings as UTF8 rather than ASCII 7 bits
-r, --reformat When set, file content is replaced by a reformatted
version. File must not be '-'.
Example
Below is the result of formatting a non-trivial JSON input to 80 characters wide:
{
"crs": {"type": "name", "properties": {"name": "urn:ogc:def:crs:EPSG::4326"}},
"totalFeatures": 116570,
"type": "FeatureCollection",
"features": [
{
"geometry": {
"type": "Polygon",
"coordinates": [
[[-3.59, 48.28], [-3.57, 48.28], [-3.54, 48.28], [-3.53, 48.26],
[-3.51, 48.25], [-3.49, 48.24], [-3.47, 48.22], [-3.48, 48.21],
[-3.5, 48.2], [-3.5, 48.18], [-3.48, 48.17], [-3.49, 48.15],
[-3.52, 48.15], [-3.53, 48.14], [-3.56, 48.14], [-3.58, 48.14],
[-3.59, 48.15], [-3.58, 48.17], [-3.58, 48.19], [-3.57, 48.21],
[-3.57, 48.23], [-3.58, 48.25], [-3.6, 48.26], [-3.59, 48.28],
[-3.59, 48.28]]]
},
"properties": {
"lastrevision": "2016-02-17T15:40:00Z",
"probability": 0,
"convectiontype": "ASPOC3D",
"directiontowards": 90.06896,
"top": 310,
"phasetype": null,
"convectioncelltopvariation": "CONSTANT",
"intensity": "LIGHT",
"base": 0,
"identifier": "OPIC_RADAR.1.201602171540000060_310",
"speed": 9.1,
"obsorfcsttime": "2016-02-17T16:40:00Z"
},
"type": "Feature",
"id": "convectionAirm.3449590",
"geometry_name": "extent"
}
]
}
Metadata
Release files for jsview 1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jsview-1.2.tar.gz | 6.7 kB | Without provenance | Details for jsview-1.2.tar.gz |
Release files / jsview-1.2.tar.gz
| Download URL | jsview-1.2.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
910af54247e292f7259f8cfb6414a8f8a4078eef72011f4e215fddd452c2801e
|
|
BLAKE2b-256 checksum How to use checksums |
a84b2405f739da09b42b53d4e290e1295c1a0b72a3522b3b6a6093239a57455b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.21.0 setuptools/41.1.0 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.8.0
|
Security for jsview 1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.