command line tool to navigate JSON files with basic SQL-like queries

Overview

navi-json

command line tool to navigate JSON files with basic SQL-like queries.

The name plays with the assonance with the word 'navigator', at least in the way I pronounce the word 'JSON', but I didn't focus a lot on the name.

Purpose

The main purposes of this tool are two:

  • to study and understand better the Rust language. I felt the need to try something outside the traditional exercises and I wanted to build something useful; I thought that this could be a good compromise.
  • to have something that helps me navigate a 18MB JSON file with tens of thousands of objects that we use at work ("why aren't you using a database!?" yeah, I don't know)

I think that something like this already exists, and if not, there must be a reason. Anyway I wanted to challenge myself and try to develop my own. For my scope this tool does not need to be complicated, I won't add anything complex like JOINs or CASE. This is my first time writing something in Rust that is not a pure and incomplete exercise, so it surely won't be well designed, elegant or optimized, at least for now.

Dependencies

navi-json is a command line tool, so it obviously needs to parse arguments; for that I decided to use 'clap' to study the usage of crates and to spend less time on parsing arguments and writing help commands. The second dependency is obviously 'json', which helps me a lot with JSON data type manipulation.

Among the first things I decided to do with this project was to eliminate the unwrap() method. I am aiming to build something for production usage, so the unwrap is only on the test functions. To do so I think I will probably use thiserror or something similar. Until now I just used a generic error but I will focus more on that later on.

Feature

The main usage of the tool is to filter through json objects or arrays, the result will always be an array.

Ready

The first features I introduced were the ones I thought simpler:

  • skip, you can skip the first n results.
  • limit, you can limit the final number of results
  • select, you can select specific properties to view in the results. You can select nested properties with dot notation and if a property does not exists it will have as value the string "not found". I know this is not the best choice, I needed something different from null, so I put that but it will change shortly.

To be made

  • select for arrays elements, I would like to add the possibility to select only the nth element of an array property.
  • where, the obvious goal of this tool is to search and filter by condition, so a 'where' clause is a must
  • count, I would like to add a count clause to just get the number of the results instead of the complete list
You might also like...
JSON parser which picks up values directly without performing tokenization in Rust
JSON parser which picks up values directly without performing tokenization in Rust

Pikkr JSON parser which picks up values directly without performing tokenization in Rust Abstract Pikkr is a JSON parser which picks up values directl

Strongly typed JSON library for Rust

Serde JSON   Serde is a framework for serializing and deserializing Rust data structures efficiently and generically. [dependencies] serde_json = "1.0

JSON implementation in Rust
JSON implementation in Rust

json-rust Parse and serialize JSON with ease. Changelog - Complete Documentation - Cargo - Repository Why? JSON is a very loose format where anything

Rust port of gjson,get JSON value by dotpath syntax

A-JSON Read JSON values quickly - Rust JSON Parser change name to AJSON, see issue Inspiration comes from gjson in golang Installation Add it to your

A rust script to convert a better bibtex json file from Zotero into nice organised notes in Obsidian

Zotero to Obsidian script This is a script that takes a better bibtex JSON file exported by Zotero and generates an organised collection of reference

Easily create dynamic css using json notation

jss! This crate provides an easy way to write dynamic css using json notation. This gives you more convenient than you think. Considering using a dyna

Decode Metaplex mint account metadata into a JSON file.

Simple Metaplex Decoder (WIP) Install From Source Install Rust. curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh Clone the source: git c

A node package based on jsonschema-rs for performing JSON schema validation

A node package based on jsonschema-rs for performing JSON schema validation.

Typify - Compile JSON Schema documents into Rust types.

Typify Compile JSON Schema documents into Rust types. This can be used ... via the macro import_types!("types.json") to generate Rust types directly i

Owner
Giulio Toldo
Giulio Toldo
Jq - Command-line JSON processor

jq jq is a lightweight and flexible command-line JSON processor. , Unix: , Windows: If you want to learn to use jq, read the documentation at https://

Stephen Dolan 23.9k Jan 4, 2023
jless is a command-line JSON viewer

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.

null 3.5k Jan 8, 2023
Get JSON values quickly - JSON parser for Rust

get json values quickly GJSON is a Rust crate that provides a fast and simple way to get values from a json document. It has features such as one line

Josh Baker 160 Dec 29, 2022
rurl is like curl but with a json configuration file per request

rurl rurl is a curl-like cli tool made in rust, the difference is that it takes its params from a json file so you can have all different requests sav

Bruno Ribeiro da Silva 6 Sep 10, 2022
An Emmet-like language that produces JSON, TOML, or YAML

.august:true August is an Emmet-like language that produces JSON, TOML, or YAML from a single-line concise selector-like syntax. If you aren't familia

Yoav Lavi 39 Aug 17, 2023
JSON model for interacting with nftables' nft command

nftables-json Serde JSON model for interacting with the nftables nft executable Provides Rust types that map directly to the nftables JSON object mode

Alex Forster 3 Jan 8, 2023
A tool for outputs semantic difference of json

jsondiff A tool for outputs semantic difference of json. "semantic" means: sort object key before comparison sort array before comparison (optional, b

niboshi 3 Sep 22, 2021
CLI tool to convert HOCON into valid JSON or YAML written in Rust.

{hocon:vert} CLI Tool to convert HOCON into valid JSON or YAML. Under normal circumstances this is mostly not needed because hocon configs are parsed

Mathias Oertel 23 Jan 6, 2023
A JSON Query Language CLI tool built with Rust 🦀

JQL A JSON Query Language CLI tool built with Rust ?? ?? Core philosophy ?? Stay lightweight ?? Keep its features as simple as possible ?? Avoid redun

Davy Duperron 872 Jan 1, 2023
Smol cli tool that converts Happy Scribe JSON to VTT understood by Podlove.

happyscribe2podlove Super smol cli tool that converts JSON from Happy Scribe to a sane VTT format that works with the Podlove Publisher. Get started E

Arne Bahlo 2 Feb 7, 2022