import org.json.JSONArray;
import org.json.JSONObject;
//jsonData的数据格式:[{ "id": "27JpL~jd99w9nM01c000qc", "version": "abc" },{ "id": "27JpL~j6UGE0LX00s001AH", "version": "bbc" },{ "id": "27JpL~j7YkM0LX01c000gt", "version": "Wa_" }]
JSONArray arr = new JSONArray(jsonData);
for (int i = 0; i < arr.length(); i++) {
JSONObject temp = (JSONObject) arr.get(i);
String id = temp.getString("id");
String id = temp.getString("version");
}
func.apply(thisValue, [arg1, arg2, ...])
func(arg1, arg2, ...)
> Math.max.apply(null, [10, -1, 5]) 10
>Math.max(1,null) //相当于Math.max(1,0) 1 >Math.max(1,undefinded) //相当于Math.max(1,NaN) NaN >Math.max(0,-0) //正零比负零大,和==不同 0 >Math.max(-0,-1) //负零比-1大 -0
> ["a",,"b"].forEach(function (x) { console.log(x) })
a
b
> ["a",undefined,"b"].forEach(function (x) { console.log(x) })
a
undefined
b
>for (i in ["a", "b"]) { console.log(typeof i) //数组的索引实际上是个字符串 }"string""string">["a", "b"].forEach(function (x, i) {
console.log(typeof i) //这里的i实际上不是索引,只是个数字类型的累加器 })"number""number"
> 1 in ["a",,"b"] false > 1 in ["a", undefined, "b"] true
> ["a",,"b"][1] undefined > ["a", undefined, "b"][1] undefined
> Array.apply(null, ["a",,"b"]) [ 'a', undefined, 'b' ]
> function returnArgs() { return [].slice.call(arguments) }
> returnArgs.apply(null, ["a",,"b"])
[ 'a', undefined, 'b' ]
> Array.apply(null, [ 3 ]) [ , , ]
function fillHoles(arr) {
var result = [];
for(var i=0; i < arr.length; i++) {
result[i] = arr[i];
}
return result;
}
> fillHoles(["a",,"b"]) [ 'a', undefined, 'b' ]
> _.compact(["a",,"b"]) [ 'a', 'b' ] > _.compact(["a", undefined, "b"]) [ 'a', 'b' ] > _.compact(["a", false, "b"]) [ 'a', 'b' ]
> Array.prototype.concat.apply([], [["a"], ["b"]]) [ 'a', 'b' ]
> Array.prototype.concat.apply([], [["a"], "b"]) [ 'a', 'b' ]
> Array.prototype.concat.apply([], [[["a"]], ["b"]]) [ [ 'a' ], 'b' ]
> _.flatten([[["a"]], ["b"]]) [ 'a', 'b' ]
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有