Retrieve Data from JSON – JSON Selector

Category: Javascript , Recommended | December 28, 2018
Author: gizt
Views Total: 320
Official Page: Go to website
Last Update: December 28, 2018
License: MIT

Preview:

Retrieve Data from JSON – JSON Selector

Description:

A simple, performant, and easy-to-use JSON selector that makes it easier to retrieve any data from JSON you provide.

How to use it:

Install the JSON Selector with NPM.

# NPM
$ npm install @gizt/selector --save

Import the JSON Selector.

// ES 6
import select from '@gizt/selector';

// CommonJS:
const select = require('@gizt/selector');

Example usages:

// JSON data
{
  "users": [
    {
      "name": "John",
      "friends": [
        {
          "name": "F1"
        }
      ]
    },
    {
      "name": "Joe",
      "friends": [
        {
          "name": "F2"
        }
      ]
    },
    {
      "name": "Jane",
      "friends": [
        {
          "name": "F3"
        }
      ]
    }
  ]
}
users[].friends[].name
users[].*  // or `users[].n*`, `users[].*ds`
users[1].name // or `users[1:].name`, `users[:1].name`

 

You Might Be Interested In:


Leave a Reply