Giter Club home page Giter Club logo

json-parser's Introduction

Json Parser

This is a experimental tool that I create for educational purposes, it's based in the jq works

With this tool you can parse json-like strings, and get some properties (like jq package)

Installation

To install json-parser first clone the repository:

mkdir -p ~/repo && cd ~/repo
git clone https://github.com/AlphaTechnolog/json-parser.git json-parser
cd json-parser

Then run the install.sh script:

sudo ./install.sh

Usage

You can parse json-like strings, passing it as a argument to json-parser like this:

json-parser '{"hello": "world"}'

It will print some output like this:

{ hello: 'world' }

And you can pass expressions as argument like this:

$ json-parser '{"hello": "world"}' '.hello'

It will print:

world

Because the expressions is a javascript accessor-like

Complex Usage

This is a more complex usage of the accessors

$ json-parser '{"hello": [0, [{"world": "hello"}]]}' '.hello[1][0].world'
hello

You can execute some javascript sentences in the expression, like this

$ json-parser '{"message": "You are "}' '.message + "beautiful"'
You are beautiful

Passing json-like strings from stdin

You can pass json-like strings from stdin, with commands like this:

$ echo '{"hello": "world"}' | jq > app.json
$ cat app.json | json-parser --stdin '.hello'
world

Or with a curl command:

$ curl http://localhost:8000/api/v1/todo/fetchall | json-parser --stdin '.todo[0]'
{
  name: "Go to the park",
  description: "I want to go to the park",
  completed: true
}

Enjoy

Thank you for read me, and thank you for use json-parser, if you like my work, please give me a star :)

json-parser's People

Contributors

alphatechnolog avatar

Stargazers

 avatar

Watchers

 avatar  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.