//https://gitee.com/JeeHuangBingGui/JsonSql

JsonSqlV3.0
介绍JsonSql,可以处理对象、Json、数组的筛选、统计、分组等功能,支持方法或sql语句。
https://gitee.com/JeeHuangBingGui/JsonSql
官方QQ群 798247492
https://jq.qq.com/?_wv=1027&k=5SLgtsI

AI_ServerV2.0
提供AI_Person_Server.exe直接运行
提供HTTP接口服务
行人识别和分析HTTP服务端等
https://gitee.com/JeeHuangBingGui/AI_Server

OpenSoftFace
开源人脸考勤系统
https://gitee.com/JeeHuangBingGui/OpenSoftFace

FastBigData
敏捷大数据研发的分布式计算平台
https://gitee.com/JeeHuangBingGui/FastBigDate

//对象用$.x ,数组用$[index]

//查询对象或Json或数组

var jsonArray = [
    { "user": { "id": 100, "screen_name": "d_linq" }, "text": "to objects" },
    { "user": { "id": 130, "screen_name": "c_bill" }, "text": "g" },
    { "user": { "id": 155, "screen_name": "b_mskk" }, "text": "kabushiki kaisha" },
    { "user": { "id": 301, "screen_name": "a_xbox" }, "text": "halo reach" }
]
var jsonArray = [
    [100,"d_linq","to objects"],
    [130,"c_bill","g"],
    [155,"b_mskk","kabushiki kaisha"],
    [301,"a_xbox","halo reach"]
]

// [“b_mskk:kabushiki kaisha”, “c_bill:g”, “d_linq:to objects”]

var queryResult = Enumerable.From(jsonArray)
    .Where(function (x) { return x.user.id < 200 })
    .OrderBy(function (x) { return x.user.screen_name })
    .Select(function (x) { return x.user.screen_name + ':' + x.text })
    .ToArray();

// shortcut! string lambda selector

var queryResult2 = Enumerable.From(jsonArray)
    .Where("$.user.id < 200")
    .OrderBy("$.user.screen_name")
    .Select("$.user.screen_name + ':' + $.text")
    .ToArray();

//数组

var queryResult2 = Enumerable.From(jsonArray)
    .Where("$[0] < 200")
    .OrderBy("$[1]")
    .Select("$[1] + ':' + $[2]")
    .ToArray();

var jsonArray = [
 { "StuID": 1, "StuName": "James", "Age": 30, "Country": "USA" },
 { "StuID": 2, "StuName": "Byant", "Age": 36, "Country": "USA" },
 { "StuID": 3, "StuName": "Lin", "Age": 30, "Country": "Taiwan" },
 { "StuID": 4, "StuName": "Yao", "Age": 30, "Country": "Shanghai" },
 { "StuID": 5, "StuName": "James", "Age": 30, "Country": "USA" },
 { "StuID": 6, "StuName": "Byant", "Age": 36, "Country": "USA" },
 { "StuID": 7, "StuName": "Lin", "Age": 30, "Country": "Taiwan" },
 { "StuID": 8, "StuName": "zhangsan", "Age": 30, "Country": "China" },
];
JsonSql.From(jsonArray)
.Where("$.Age <= 30")//筛选
.Distinct("$.StuName")//去重
.OrderBy("$.StuID")//排序
.Skip(0)//跳过0条
.Take(2)//取2条
.ToJSON()
//.ToString()
//.ToArray()

//列获取

JsonSql.From(jsonArray)
.Select("{StuName:$.StuName,age:$.Age}")
.ToJSON()

//合计

JsonSql.From(jsonArray)
.Sum("$.Age")
.ToJSON()

//Min

JsonSql.From(jsonArray)
.Where("$.Age = JsonSql.From(jsonArray).Min('$.Age')")
.ToJSON()

//数组转对象

JsonSql.From(gp)
.Select("{day:$[0],close:$[1]}")
.Where("$.close == JsonSql.From(gp).Min('$[1]')")
.ToJSON()

//like 包含

JsonSql.From(gp)
.Select(“{day:$[0],close:$[2]}”)
.Where(“$.day.indexOf(‘2020-03-19’) != -1”)
.ToJSON()

//直接写sql语句

$JsonSql(" select {day:$[0],close:$[2]} from gp where $.close == JsonSql.From(gp).Min('$[2]')")
$JsonSql(" from gp where $[2] == JsonSql.From(gp).Min('$[2]')")

//ForEach

var jsonArray = [
  {{ "StuID": 1, "StuName": "James", "Age": 30, "Country": "USA" },
  { "StuID": 2, "StuName": "Byant", "Age": 36, "Country": "USA" },
  { "StuID": 3, "StuName": "Lin", "Age": 30, "Country": "Taiwan" },
  { "StuID": 4, "StuName": "Yao", "Age": 30, "Country": "Shanghai" }
];}
var querResult = JsonSql.From(jsonArray)
  .Where(function (x) { return x.Age <= 30; })
  .OrderBy(function (x) { return x.StuID; })
  .ToArray()
  .ForEach(function (i) {
     document.write(i.StuID + ";" + i.StuName + ";" + i.Age + ";" + i.Country + "<br/>");
});

//交集、差集、并集

var arr1 = [1, 412, 53, 25];
var arr2 = [53, 25,22,20];
Enumerable.From(arr1).Intersect(arr2).ForEach(function(i) {
  document.write(i + ";"); //53,25
});
Enumerable.From(arr1).Except(arr2).ForEach(function (i) {
  document.write(i + ";"); // 1;412
});
Enumerable.From(arr1).Union(arr2).ForEach(function (i) {
  document.write(i + ";"); // 1;412;53;25;22;20;
});

//Alternate、Contains

Enumerable.Range(1, 5).Alternate('*').ForEach(function (i) {
  document.write(i + ";"); //;*;2;*;3;*;4;*;
});
var r = Enumerable.Range(1, 5).Contains(3);
document.write(r); //ture
文档更新时间: 2023-02-02 06:58   作者:admin