Skip to content
Use Glance with JSON
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
test
.gitignore
.npmignore
package-lock.json
package.json
readme.md
wallaby.js
webpack.config.js

readme.md

Glance JSON

npm install glance-json

Example

import glanceJSON from 'glance-json';

let data = {
	contact: {
		firstName: "John",
		lastName: "Doe",
		phoneNumber: 555-555-555
	}
};

glanceJSON(data, "John > phoneNumber") // 555-555-555

Options

key

Perform an exact match search on keys

let data = {
	square: {
		backgroundColor: "blue",
		color: "red"
	}
};

glanceJSON(data, "color#key"); // red

value

Perform an exact match search on values

let data = {
	contacts: [{
		firstName: "John",
		lastName: "Doe",
		phoneNumber: 555-555-555
	},
    {
    	firstName: "Johnny",
       	lastName: "Doey",
       	phoneNumber: 555-555-555	
    }]
};

glanceJSON(data, "John#value > phoneNumber") // 555-555-555

key-contains

Perform a contains text search on keys

let data = {
	contact: {
		firstName: "John",
		lastName: "Doe",
		phoneNumber: 555-555-555
	}
};

glanceJSON(data, "first#key-contains > phoneNumber") // 555-555-555

value-contains

Perform a contains text search on values

let data = {
	contact: {
		firstName: "John",
		lastName: "Doe",
		phoneNumber: 555-555-555
	}
};

glanceJSON(data, "555#value-contains > firstName") // John

exact text

Perform a match search on key's exact text

let data = {
	contact: {
		Name: "John Doe",
		firstName: "John",
		lastName: "Doe",
		phoneNumber: 555-555-555
	}
};

glanceJSON(data, "Name #exact-text"); // John Doe
You can’t perform that action at this time.