Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Query Language for JSON?
WhatsApp
Shirsendu Nandi
13y
7.9
k
0
0
25
Blog
A new data querying tool for has been added to
Dojo
1.2. JSONQuery is a new module intended to succeed and improve upon the JSONPath module introduced in Dojo 1.1. JSONQuery provides a comprehensive set of data querying tools including filtering, recursive search, sorting, mapping, range selection, and flexible expressions with wildcard string comparisons and various operators. JSONQuery provides
safe evaluation with language agnostic expressions
that prevents arbitrary code execution. It also uses intuitive
result-based evaluation
that allows successive query operations. Furthermore, the new JSONQuery module provides significant performance improvements, with 20-100x faster execution with the common filter operation on large arrays than the JSONPath module. JSONQuery generally supersets the functionality of JSONPath and provides syntax that matches and behaves like JavaScript where the syntax intersects for maximum ease of use.
Syntex:
var
results
=
jLinq
.
from
(
records
.
users
)
//you can join records
.
join
(
records
.
locations
,
"location"
,
"locationId"
,
"id"
)
//write queries on the data
.
startsWith
(
"firstname"
,
"j"
)
.
or
(
"k"
)
//automatically remembers field and command names
//even query joined items
.
equals
(
"location.state"
,
"TX"
)
//and even do custom selections
.
select
(
function
(
rec
)
{
return
{
fullname
:
rec
.
firstname
+
" "
+
rec
.
lastname
,
city
:
rec
.
location
.
city
,
ageInTenYears
:
(
rec
.
age
+
10
)
};
});
data = {foo:
"bar"
};
results = dojox.json.query(
"$.foo"
,data);
results ->
"bar"
1
2
3
data = {foo:
"bar"
};
results = dojox.json.query(
"$.foo"
,data);
results ->
"bar"
Up Next
Convert JSON String to DataTable in ASP.Net
Ebook Download
View all
ASP.NET GridView Control Pocket Guide
Read by 10.7k people
Download Now!
Learn
View all
Membership not found