:6.743KB : :1 :2020-02-23 20:42:07
功能使用
XRoute('X.A','111') = 111
XRoute('X.A') = 111
XRoute('X.A') = {X:{A:111}}
function XRoute() {
let Keys,Value,Cache,Path;
this.Cache = this.Cache || {};
if (arguments.length == 1) {
Keys = arguments[0];
Path = Keys.split('.');
for (let Route = 0; Route < Path.length; Route++) {
if (Route) {
if (Route + 1 == Path.length) {
Cache = Cache[Path[Route]] = Cache[Path[Route]] || {};
} else {
Cache[Path[Route]] = Cache[Path[Route]] || {};
}
} else {
Cache = this.Cache[Path[Route]] = this.Cache[Path[Route]] || {};
}
}
} else if (arguments.length == 2) {
Keys = arguments[0];
Value = arguments[1];
Path = Keys.split('.');
for (let Route = 0; Route < Path.length; Route++) {
if (Route) {
if (Route + 1 == Path.length) {
if (Value) {
Cache = Cache[Path[Route]] = Value;
} else {
Cache[Path[Route]] = Cache[Path[Route]] || {};
}
} else {
Cache[Path[Route]] = Cache[Path[Route]] || {};
}
} else {
Cache = this.Cache[Path[Route]] = this.Cache[Path[Route]] || {};
}
}
} else {
Cache = JSON.stringify(this.Cache);
}
return Cache;
}
JSON.Input (JSON.toString (“users”))
调试输出 (JSON.Output ())
调试输出 (JSON.Eval (“code.username”).取文本 ())
调试输出 (JSON.Eval (“code.qq”).取数值 ())
调试输出 (JSON.Eval (“code.wx”).取文本 ())
调试输出 (“数量”, JSON.Count (“code”))
调试输出 (“变量组合”, JSON.Eval (“code.name +' = '+ code.wx”).取文本 ())
调试输出 (“组合长度”, JSON.Eval (“(code.name +' = '+ code.wx).length”).取文本 ())'函数不需要return因为json对象会被函数直接修改。
调试输出 (“组合长度”, JSON.Eval (“(code.name +' = '+ code.wx).length”).取数值 ())
value = JSON.Eval (“(code.name +' = '+ code.wx).length = 16”)
调试输出 (“组合长度”, value.取逻辑值 ())
value = JSON.Eval (“code.time”)
调试输出 (value.取日期 ())
调试输出 (“name 内容长度 = ” + JSON.Eval (“code.name.length”).取文本 ())
调试输出 (“特殊扩展”)
JSON.Eval (“function add(a,b){return a+b;}”)
value = JSON.Eval (“add(code.money,code.tt)”)
调试输出 (value.取文本 ())
02-17轻量级的json解析器,基于V8引擎
02-16支持懒加载的类编写的json解析工具
02-04json加载编辑修改写出
02-03V8 js函数绑定到易语言函数
02-02V8 js函数绑定到易语言函数
02-02易语言基于V8纯JS JSON解析
01-29JS_Json模块源码
01-09zyjson合并添加数组对象的调试工具