JS traversal JSON array and get JSON array length operation example [Test available]

The instance of this article describes the JS traversal JSON array and acquires the JSON array length operation. Share to everyone for reference, specifically:

  VAR Questions = data.data.questionNaire. Questions; // Traverse the JSON array for (VAR I in Questions) {if (Questions [I] .Type == ') {Alert (' Danxuan ');}}  

Get JSON array length:

Function getjsonLength (json) {var jsonLength = 0; for (Var i in json ) {JSONLENLENGTH;}
  Comprehensive test example:  

/ / Simple JSON arrays: var jsondemo = {“name”: “\ u811a \ u672c \ u4e4b \ u5bb6”, “addtime”: “2018-12-12”, “username”: “JB51”, “ID”: 5} // Traverse the JSON array: for (var i in jsondemo) {console.log (jsondemo [i]);} // Get JSON array length: function getjsonLength (json) {var jsonLength = 0;for (var i in json) {jsonLength ++;} return jsonLength;} console.log ( ‘array length:’ + getJsonLength (jsonDemo))

 Use  Online HTML / CSS / JavaScript code running tool : http: //tools.jb51.net/code/HtmlJsRun test code above obtained results are as follows: 

PS: here again recommend several related json online tools for your reference:


online JSON code is test, test, landscaping, formatting tools:


format online tools:

http: //tools.jb51. net / code / jsonformat

online XML / JSON interchangeable tools:

Code format online / beautification / compression / editing / conversion tools:


online json compression / escape tool:

more about JavaScript to view the content site topic: “JavaScript in json operating skills summary “,” JaVascript Finding Algorithm Skill Summary “,” JavaScript Error and Debug Skill Summary “,” JavaScript Data Structure and Algorithm Skill Summary “,” JavaScript Overclic Algorithm and Skills Summary “and” Summary of JavaScript Mathematical Computing “

I hope this article The JavaScript programming is helpful.

© Copyright Notice
Just support it if you like
comment Grab the couch

Please log in to comment