Jless
jless is a terminal-based JSON viewer. I consider it a perfect counterpart to jq
. With these two tools, you can manipulate JSON either on the stream, allowing all sorts of interesting transformation possibilities. Given the prominence of JSON at this point, being familiar with these tools can save a ton of time during development or problem-solving.
jless
is the easiest way to make sense of a very complex or deeply-nested JSON data. As the expansion of JSON has added to the complexity of things it needs to describe. Data structures can now be very large and non-intuitive upon first glance. In order to get some feel for the "shape" of the data, deeply nested structures force us to expand things either specifically or entirely, based on the fields we might be driving at. When everything is expanded, I find myself constantly paging up and paging down, only to lose track of what I was seeking to compare by the tedious effort of searching for a corresponding nested structure. It's no fun.
UI Text Rendered:
1 ▼ (4) {"@context": […], type: "Feature", geometry: {…}, properties: {…}}
2 ▽ "@context": (2) ["https://geojson.org/geojson-ld/geojson-context.jsonld", {…}]
3 [0]: "https://geojson.org/geojson-ld/geojson-context.jsonld"
4 ▽ [1]: (5) {"@version": "1.1", wx: "https://api.weather.gov/ontology#", geo: "http://www.opengis.net/ont/geosparql#", unit: "http://codes.wmo.int/common/unit/", "@vo…": …}
5 "@version": "1.1"
6 wx: "https://api.weather.gov/ontology#"
7 geo: "http://www.opengis.net/ont/geosparql#"
8 unit: "http://codes.wmo.int/common/unit/"
9 "@vocab": "https://api.weather.gov/ontology#"
12 type: "Feature"
13 ▽ geometry: (2) {type: "Polygon", coordinates: […]}
14 type: "Polygon"
15 ▽ coordinates: (1) [[[…], […], […], […], […]]]
16 ▽ [0]: (5) [[…], […], […], […], […]]
17 ▽ [0]: (2) [-115.28668089999999, 36.187112599999999]
18 [0]: -115.28668089999999
19 [1]: 36.187112599999999
21 ▽ [1]: (2) [-115.2825457, 36.164969999999997]
22 [0]: -115.2825457
23 [1]: 36.164969999999997
25 ▽ [2]: (2) [-115.2551244, 36.168304499999998]
26 [0]: -115.2551244
27 [1]: 36.168304499999998
29 ▽ [3]: (2) [-115.25925409999999, 36.190447499999998]
30 [0]: -115.25925409999999
31 [1]: 36.190447499999998
33 ▽ [4]: (2) [-115.28668089999999, 36.187112599999999]
34 [0]: -115.28668089999999
35 [1]: 36.187112599999999
40 ▽ properties: (8) {updated: "2023-09-27T19:48:42+00:00", units: "us", forecastGenerator: "BaselineForecastGenerator", generatedAt: "2023-09-28T01:13:40+00:00", updat…: …, …}
41 updated: "2023-09-27T19:48:42+00:00"
42 units: "us"
43 forecastGenerator: "BaselineForecastGenerator"
44 generatedAt: "2023-09-28T01:13:40+00:00"
45 updateTime: "2023-09-27T19:48:42+00:00"
46 validTimes: "2023-09-27T13:00:00+00:00/P8D"
47 ▽ elevation: (2) {unitCode: "wmoUnit:m", value: 779.98320000000001}
48 unitCode: "wmoUnit:m"
49 value: 779.98320000000001
This tool allows you to expand nodes exclusively or deeply including siblings. Toggling these states in a real-time ui, rather than printing to standard output helps give a better indication of the structures you are working with quickly. Expanding and searching for fields through parsing can be tedious, especially with unfamiliar data. I often use jless immediately as soon as I get JSON data whose structure I am unfamiliar, with barely any paging up or down.