Home >Web Front-end >JS Tutorial >Introduction to 8 ways to query the data structure of json_Basic knowledge
8 ways to query the data structure of json:
JsonSQL
JsonSQL implements the function of querying in the json data structure using SQL select statements. Home page: http://www.trentrichardson.com/jsonsql/
Example:
JSONPath
JSONPath is like XPath for JSON data structures. Home page: http://goessner.net/articles/JsonPath/
Example:
jfunk
jFunk allows you to retrieve (and soon manage) complex JSON or Javascript objects. The design of jFunk API is almost similar to jQuery API. It directly copies jQuery's API, except for those targeting the DOM.
Homepage: http://code.google.com/p/jfunk/
Example:
TaffyDB
Have you ever noticed in the past that Javascript object literals look a lot like records? If you wrap them in an array, do they look like a database table? TaffyDB is a Javascript library that provides powerful database functionality to implement previous ideas, greatly improving the way you work with data in Javascript.
Homepage: http://www.taffydb.com/
Example:
linq.js
linq.js - LINQ in Javascript
objeq
objeq is a simple library that implements real-time query of POJSO (Plain-Old JavaScript Objects, ordinary Javascript objects). Home page: https://github.com/agilosoftware/objeq
json:select()
Query JSON using CSS-like selectors. Home page: http://jsonselect.org/#tryit
Javascript array filtering method in Paul’s Programming Pearls, homepage: http://www.paulfree.com/28/javascript-array-filtering/#more-28
Currently this is my favorite way to query JSON data structures. It's very simple, and according to the author it's very fast.
The idea behind it is similar to John Resig's JavaScript Micro-Templating: use the correct expression to convert a very simple string into a Javascript function.
Of course, there are more powerful solutions. The prototype implemented by Paul also lacks syntax checking for filter expressions, but I believe you should be able to solve Javscript's syntax checking yourself.