Articlage

What is jsonQuery

jsonQuery is a jQuery library that allows you to  filter and query data in json format.
 
For instance,  we start from the following data in json format:
 
var users = [
	{ 'user': 'jon',  'age': 40, 'active': true , 'nSon':10},
	{ 'user': 'susan',    'age': 40, 'active': false , 'nSon':5},
	{ 'user': 'james', 'age': 1,  'active': true, 'nSon':8 }
];	

we can make the following query to filter and select the data we want:

var jq=new jsonQuery(users);
	
var re6=jq.where(
{
	major:{'age':'0','nSon':4},
	equal:{'active':true},
	minor:{'nSon':40},
	majorOrEqual:{'nSon':10},
	minorOrEqual:{'nSon':40},								
}).select(['user','age']);

I get the following result:

[
	{
		"user": "jon",
		"age": 40
	}
]

 

©2012 Articlage. Articlage is not responsible for the content shown here or the links, attachments, images or any other reference that may contain the different articles and does not warrant the accuracy of information.