Giter Site home page Giter Site logo

jsonflat's Introduction

Jsonflat

Jsonflat is a utility to convert JSONs into flatter, greppable form. Given the following json:

{
    "foos": [
        {
            "name": "a",
            "frobnicity": 50
        },
        {
            "name": "b",
            "frobnicity": 50
        }
    ]
}

it spits out:

.foos[0](name=a).frobnicity: 50
.foos[0](name=a).name: "a"
.foos[1](name=b).frobnicity: 50
.foos[1](name=b).name: "b"

Note that name key is special and is included in paths. This is to make paths more meaningful if your data representation is not a dict, but rather list of named objects.

It also works when jsons are embedded in plaintext:

[2020-02-02 20:02] Got response: {
    "code": 404,
    "message": "nothing there"
}. Ignoring.
[2020-02-02 20:02] Got response: .code: 404
[2020-02-02 20:02] Got response: .message: "nothing there"
[2020-02-02 20:02] Got response: {…}. Ignoring.

Usage

Reads from stdin, writes to stdout.

Example

command that returns json | jsonflat | grep "thing"

There's also a stripcommonprefix command included that should help with long paths:

command that returns json | jsonflat | grep "thing" | stripcommonprefix

Installation

Linux

Check out the releases.

Manual

  1. Install Rust
  2. cargo install --git https://github.com/krdln/jsonflat

License

TODO

jsonflat's People

Contributors

krdln avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.