ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
结论:果断用 `jsonsql`。 官网:http://www.trentrichardson.com/jsonsql/ 当然,有人说用其他查询方式!如下:http://www.haorooms.com/post/js_json_JsonSQL_jfunk 。(供参考) # 如图 ![mark](http://qiniu.newthink.cc/blog/20171123-142455387.png) # 代码 > 这里 `where` 一定要用 括号,否则查不出来。 ``` <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="https://cdn.bootcss.com/jquery/1.11.3/jquery.js"></script> <!-- 官网 http://www.trentrichardson.com/jsonsql/ --> <script src="jsonsql-0.1.js"></script> </head> <span id="test">现金</span> <body> <script> var paylist = [ {"id":"1","paymode": '1', "payname": "现金", "paymoney": "20"} , {"id":"3","paymode": '2', "payname": "支付宝", "paymoney": "50"} , {"id":"2","paymode": '1', "payname": "现金", "paymoney": "40"} ]; //根据payname现金进行筛选 var result1 = jsonsql.query('select * from paylist order by id desc',paylist); var result2 = jsonsql.query('select * from paylist where (payname=="现金") order by id desc',paylist); console.log(result1); console.log(result2); </script> </body> </html> ``` # 官方案例 ``` select title,url from json.channel.items where (category=='bla' || category=='bla bla') order by title desc limit 5,10 jsonsql.query("select * from json.channel.items order by title desc",json); jsonsql.query("select title,url from json.channel.items where (category=='javascript' || category=='vista') order by title,category asc limit 3",json); ```