parse a JSON Array in JavaScript

 

parse a JSON Array in JavaScript

 

Fields in JSON are almost the same as fields in JavaScript. In JSON, field values ​​must be string, number, object, array, boolean, or null. In JavaScript, field values ​​can be all of the above plus any other valid JavaScript expression, including functions, data, and undefined.

 

Use the JSON.parse() method to insert a JSON array, eg JSON.parse(arr). The method parses a JSON string and returns its JavaScript value or object equivalent. If the specified parameter is not valid JSON, the JSON.parse method throws a SyntaxError exception

myJSON = '["Ford", "BMW", "Fiat"]';
myArray = JSON.Parse(myJSON);

Tags:

Share:

Related posts