pauljuliusmartinez/jless

jless is a command-line JSON viewer

replacement for whatever combination of less, jq, cat and your

jless is a command-line JSON viewer. Use it as a replacement for whatever combination of less, jq, cat and your editor you currently use for viewing JSON files. It is written in Rust and can be installed as a single standalone binary.

jless is under active development. I often stream development live on Twitch.

Features

  • Clean syntax highlighted display of JSON data, omitting quotes around object keys, closing object and array delimiters, and trailing commas.
  • Expand and collapse objects and arrays so you can see both the high- and low-level structure of the data.
  • A wealth of vim-inspired movement commands for efficiently moving around and viewing data.
  • Full regex-based search for finding exactly the data you're looking for.

jless currently supports macOS and Linux. Windows support is planned.

Installation

You can install jless using various package managers:

Operating System / Package Manager Command
macOS - HomeBrew brew install jless
macOS - MacPorts sudo port install jless
Linux - HomeBrew brew install jless
Arch Linux pacman -U jless
Void Linux sudo xbps-install jless
NetBSD pkgin install jless
FreeBSD pkg install jless

If you have a Rust toolchain installed, you can install jless from source by running cargo install jless.

The releases page also contains links to binaries for various architectures.

Dependencies

On Linux systems, X11 libraries are needed to build clipboard access if building from source. On Ubuntu you can install these using:

sudo apt-get install libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev

Website

jless.io is the official website for jless. Code for the website is contained separately on the website branch.

Logo

The mascot of the jless project is Jules the jellyfish.

Art for Jules was created by annatgraphics.

License

jless is released under the MIT License.

Issues

Collection of the latest Issues

JekRock

JekRock

Comment Icon1

When trying to parse any valid JSON, jless opens the preview, but when pressing any button, e.g. arrows, the following message appears at the bottom "Error: Could not parse an event".

How to reproduce

  1. run echo '{ "id": "123"}' | jless
  2. see the error message at the bottom. Also, jless doesn't let to navigate the JSON

image

Version

kllmanu

kllmanu

Feature Request
Comment Icon1

Thanks a lot for your command line json viewer, I really appreciate the effort you put into! It would be really nice if the data would be reloaded (maybe with an optional flag --reload) when the input file changes. I've tried to achieve the same with tools like entr but I always end up with lots of errors, freezing UI (navigating the json is acting weird) and I've to kill the terminal.

The messages that are "spammed" when I try to quit jless, command started with echo context.json | entr -z jless context.json: Screenshot 2022-05-29 at 10 43 30

GPery

GPery

Build
Comment Icon1

Running cargo install jless on my dev servers currently fails because it doesn't have libxcb, which is required by the crate clipboard. I was thinking maybe it could be a default feature which I could disable explicitly, or maybe check for libxcb in build script.

I can implement it if it's deemed a good idea @PaulJuliusMartinez :smile:

matiu3

matiu3

Feature Request
Comment Icon2

Allow removing all parents from the view, except for the currently entered container (map / list).


Use case: I'm running aws ec2 describe-instances - I / search for the instance I care about.

Now I'd like to zoom into that map and remove all parents from the status.

Next I'd like to /public_ip

It can be done without zooming, but because the block is so giant, I'm not sure if I'm looking at the public_ip of some other instance.


Of course you'd also want to zoom out.

I suggest the keys z for zoom and u for up Z for unzoom

chryoung

chryoung

Parsing
Comment Icon4

JSON with comments file cannot be open now. The program simply shows Unable to parse input: "Parse error" and exits.

A JSON with comments file may look like this:

dirkfeytons

dirkfeytons

Build
Comment Icon3

I upgraded from 0.7.x (don't remember which one, sorry) to the new 0.8.0 and apparently the binary now refers to some GLIBC_2.28 and GLIBC_2.29 symbols. I'm currently running Linux Mint 19.3 which is based on Ubuntu 18.04 using glibc 2.27 so 0.8.0 doesn't run there.

I realize this is a rather old distro but it's still supported until April 2023 because it was an LTS release.

I'll let you decide whether you still can/want to support this. No hard feelings if you don't and an extra incentive for me to upgrade 😄

sphinxian84

sphinxian84

Build
Comment Icon0

Staging: Windows 10 WSL2 "bullseye/sid" brew --version Homebrew 3.4.1 Homebrew/homebrew-core (git revision 7aa6ef8a215; last commit 2022-03-12)

Steps to reproduce: $ brew install jless $ jless Error: -bash: /home/linuxbrew/.linuxbrew/bin/jless: cannot execute binary file: Exec format error

roeniss

roeniss

Comment Icon5

Hi, I use Korean (ko_kr) but seems that jless doesn't support this language. given:

expected:

result:

gennaro-tedesco

gennaro-tedesco

Feature Request
Comment Icon2

jless is awesome, thank you very much for your work on it!

Description of the feature:

At the moment jless search works à la Vim, searching back and forth for patterns with /?; in particular the documentations says:

The search is not performed over the original input, but over a single-line pretty formatted version of the input JSON.

would it be possible to introduce some sort of jq grammar where we can filter via, say

and similar? Or is this already present and I overlooked it?

Thank you again for the great work!

ashton314

ashton314

Feature Request
Comment Icon1

Synopsis

Make the User Guide available in the terminal with a man page.

Description

The User Guide is great! I'd love it if this were available in the terminal as a man page. (That's the whole point of this project, right? Keep me in the comfort of a keyboard-driven environment, yes? 😃 ) ripgrep has an excellent man page that comes when you install with brew—that might furnish a good example of how to do this.

Misc

This is a beautiful little utility! Thank you so much for making it!

KindDragon

KindDragon

Build
Comment Icon1

I use Ubuntu all the time in my work, but none of the utilities I have installed offer Homebrew to install them. In my personal experience, the most popular choices are the deb-package and the classic snap app.

daniel-wells

daniel-wells

Parsing
Comment Icon0

By default Python's json module allows NaN and Infinity when serialising to json:

Though technically this isn't complient JSON, it would be nice if jless was more permissive to allow the viewing of these files?:

zachvalenta

zachvalenta

Comment Icon2

One cool idea from a similar tool (jsonui) is that of a tree-view so you can see top-level keys at a glance.

No idea if this is desirable or feasible for jless, just figured an idea for the project going forward.

brewingcode

brewingcode

Feature Request
Comment Icon2

Would it be possible to add a command line option to render the truncated strings as just a count (key-value pairs for objects, array elements for arrays)? For example, here's what jless currently says with https://api.github.com/repos/PaulJuliusMartinez/jless/commits:

I have a tool of my own for viewing JSON that shows the same structure like so:

While I don't need an exact match, I figure that jless could (optionally) produce something like:

I'm happy to give this a try if you could point me to a starting place. I know zero rust, but am familiar with lots of other languages. It looks like lineprinter.rs:fill_in_value() is where these labels are generated, and maybe from there into truncatedstrview.rs, but I quickly got lost in there.

gonzaloserrano

gonzaloserrano

Feature Request
Comment Icon0

Hello,

I find single-line previews of objects and arrays in Data Mode distracting. I'd like Data Mode to look somewhat similar to Line Mode . It would be great to have a flag or command to disable it.

Example:

Current CleanShot 2022-02-15 at 15 36 40

Proposal CleanShot 2022-02-15 at 15 36 40 copy

Thanks!

tekumara

tekumara

Feature Request
Comment Icon2

strings longer than the terminal's number of columns are truncated. would be nice to be able to word wrap these.

Versions

Find the latest versions by id

v0.8.0 - Mar 10, 2022

This new release of jless ships with two major new features: basic YAML support and copying to clipboard!

jless will now check the file extension of the input file, and automatically parse .yml and .yaml files as YAML and use the same viewer as for JSON data. Alternatively passing in a --yaml flag will force jless to parse the input as YAML and can be used when reading in YAML data from stdin. (alias yless="jless --yaml" perhaps?) YAML aliases are automatically expanded, but their corresponding anchors are not visible, nor are comments. YAML supports non-string keys, and even non-scalar keys in mappings (e.g., the key of map can be an array with multiple elements). Non-string keys are shown with square brackets, e.g., [true]: "value", instead of quotes. Non-scalar keys are handled on the screen and displayed properly, but you cannot expand and collapse their individual elements.

While navigating data, jless also now supports copying various items to your system clipboard.

  • yy will copy the value of the currently focused node, pretty printed
  • yv will copy the value of the currently focused node in a "nicely" printed one-line format
  • yk will copy the key of the current key/value pair
  • yp will copy the path from the root JSON element to the currently focused node, e.g., .foo[3].bar
  • yb functions like yp, but always uses the bracket form for object keys, e.g., ["foo"][3]["bar"], which is useful if the environment where you'll paste the path doesn't support the .key format, like in Python
  • yq will copy a jq style path that will select the currently focused node, e.g., .foo[].bar

This release also includes a couple of new movement commands, and some stability fixes. The full list of changes can be seen below.

Full list of changes

New features:

  • Support displaying YAML files with autodetection via file extension, or explicit --yaml or --json flags.
  • Support copying values (with yy or yv), object keys (with yk), and paths to the currently focused node (with yp, yb or yq).
  • Implement ctrl-u and ctrl-d commands to jump up and down by half the screen's height, or by a specified number of lines.
  • Implement ctrl-b and ctrl-f commands for scrolling up and down by the height of the screen. (Aliases for PageUp and PageDown)

Improvements:

  • Keep focused line in same place on screen when toggling between line and data modes; fix a crash when focused on a closing delimiter and switching to data mode.
  • Pressing Escape will clear the input buffer and stop highlighting search matches.

Bug Fixes:

  • Ignore clicks on the status bar or below rather than focusing on hidden lines, and don't re-render the screen, allowing the path in the status bar to be highlighted and copied.
  • Issue #61: Display error message for unrecognized CSI escape sequences and other IO errors instead of panicking.
  • Issue #62: Fix broken window resizing / SIGWINCH detection caused by clashing signal handler registered by rustyline.
  • PR #54: Fix panic when using Ctrl-C or Ctrl-D to cancel entering search input.

Other Notes:

  • Upgraded regex crate to 1.5.5 due to CVE-2022-24713. jless accepts and compiles untrusted input as regexes, but you'd only DDOS yourself, so it's not terribly threatening vulnerability.

v0.7.2 - Feb 20, 2022

New features / changes:

  • Space now toggles the collapsed state of the currently focused node, rather than moving down a line. (Functionality was previous available via i, but was undocumented; i has been unmapped.)

Bug fixes:

  • Searching now works even when input is provided via STDIN.

Internal:

  • Upgraded from structopt to clap v3

v0.7.1 - Feb 09, 2022

New features:

  • F1 now opens help page
  • Search initialization commands (/, ?, *, #) all now accept count arguments

Internal code cleanup:

  • Address a lot of issues reported by clippy
  • Remove chunks of unused code, including serde dependency
  • Fix typos in help page

v0.7.0 - Feb 07, 2022

Introducing jless, a command-line JSON viewer.

This release represents the significant milestone: a complete set of basic functionality, without any major bugs.

This GitHub issue details much of the functionality implemented to get to this point. Spiritually, completion of many of the tasks listed there represent versions 0.1 - 0.6.

The intention is to not release a 1.0 version until Windows support is added.

Information - Updated Sep 16, 2022

Stars: 2.9K
Forks: 42
Issues: 42

Serde is a framework for serializing and deserializing Rust data structures efficiently and generically

Rust Greatest JSON weapon is Serde with over 4.4K stars on github and a massive developer community. This is considered a core Rust library for every developer to learn in BRC's opinion

Serde is a framework for serializing and deserializing Rust data structures efficiently and generically

Rust 버전 JsonPath 구현으로 Webassembly와 Javascript에서도 유사한 API 인터페이스를 제공 한다

JsonPath 구현으로 Webassembly와 Javascript에서도 유사한 API 인터페이스를 제공 한다

Rust 버전 JsonPath 구현으로 Webassembly와 Javascript에서도 유사한 API 인터페이스를 제공 한다

SIMD JSON for Rust  

Rust port of extremely fast serde compatibility

SIMD JSON for Rust  

JSON-E Rust data-struct paramter crate for lightweight embedded content with objects and much more

What makes JSON-e unique is that it extensive documentation and ease of use

JSON-E Rust data-struct paramter crate for lightweight embedded content with objects and much more
JSON

111

A Rust JSON5 serializer and deserializer which speaks Serde

Deserialize a JSON5 string with from_str

A Rust JSON5 serializer and deserializer which speaks Serde

Rust JSON Parser Benchmark

Download and Generate JSON Data

Rust JSON Parser Benchmark

Read JSON values quickly - Rust JSON Parser

AJSON get json value with specified path, such as project

Read JSON values quickly - Rust JSON Parser

Rust actix json request example

Send a json request to actix, and parse it

Rust actix json request example
JSON

140

json_typegen - Rust types from JSON samples

json_typegen is a collection of tools for generating types from

json_typegen - Rust types from JSON samples

Rust JSON parsing benchmarks

This project aims to provide benchmarks to show how various JSON-parsing libraries in the Rust programming language perform at various JSON-parsing tasks

Rust JSON parsing benchmarks

A tiny command line tool written in rust to print json data as a formatted...

A tiny command line tool written in rust to print json data as a formatted table

A tiny command line tool written in rust to print json data as a formatted...

Rust RPC client for Bitcoin Core JSON-RPC

rust-jsonrpc and makes it easier to talk to the Bitcoin JSON-RPC interface

Rust RPC client for Bitcoin Core JSON-RPC
Facebook Instagram Twitter GitHub Dribbble
Privacy