JS Get the code for the length of the JSON field. This article will mainly share it with you in the form of code
//JS 获得JSON 字典的长度的代码 var jsonData = {"name":"txt1","name2":"txt2"}; function getJsonLength(jsonData) { var jsonLength = 0; for (var item in jsonData) { jsonLength++; } return jsonLength; } console.log("json对象的长度为:",getJsonLength(jsonData));
The above is the detailed content of How to get the length of JSON field in JS. For more information, please follow other related articles on the PHP Chinese website!