
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
How to iterate json array – JavaScript?
To iterate JSON array, use the JSON.parse().
Example
Following is the code −
var apiValues = [ '{"name": "John", "scores": [78, 89]}', '{"name": "David", "scores": [58, 98]}', '{"name": "Bob", "scores": [56, 79]}', '{"name": "Mike", "scores": [94, 91]}' ]; var parseJSONObject = apiValues.map(obj => JSON.parse(obj)); console.log("The original String : ", apiValues); console.log("The JSON Objects : ", parseJSONObject);
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo252.js.
Output
This will produce the following output on console −
PS C:\Users\Amit\javascript-code> node demo252.js The original String : [ '{"name": "John", "scores": [78, 89]}', '{"name": "David", "scores": [58, 98]}', '{"name": "Bob", "scores": [56, 79]}', '{"name": "Mike", "scores": [94, 91]}' ] The JSON Objects : [ { name: 'John', scores: [ 78, 89 ] }, { name: 'David', scores: [ 58, 98 ] }, { name: 'Bob', scores: [ 56, 79 ] }, { name: 'Mike', scores: [ 94, 91 ] } ]
- Related Articles
- How to iterate a JSON Array in Android?
- How to iterate a JSON Array in Android using Kotlin?
- How to iterate through and access the JSON array elements using Rest Assured?
- How to convert JSON string to array of JSON objects using JavaScript?
- JavaScript Convert an array to JSON
- How to read data from JSON array using JavaScript?
- Convert JSON array into normal json in JavaScript
- How to turn a JSON object into a JavaScript array in JavaScript ?
- Formatting dynamic json array JavaScript
- Regroup JSON array in JavaScript
- From JSON object to an array in JavaScript
- How to convert JSON text to JavaScript JSON object?
- How to iterate over objects in array and sum a property in JavaScript
- Merge JSON array date based JavaScript
- Create array from JSON object JavaScript

Advertisements