Home  >  Article  >  Web Front-end  >  How to convert json to array in javascript

How to convert json to array in javascript

coldplay.xixi
coldplay.xixiOriginal
2021-04-15 13:53:3811190browse

The method of converting json to array in javascript is through jsonStr. The code is [var jsonStr = '[1,2,3,{"a":1}]';JSON.parse( jsonStr ); ] .

How to convert json to array in javascript

The operating environment of this tutorial: Windows 7 system, JavaScript version 1.8.5, DELL G3 computer.

javascript method to convert json to array:

//array to json string

var arr = [1,2,3, { a : 1 } ];
JSON.stringify( arr );

//json string to array

var jsonStr = '[1,2,3,{"a":1}]';
JSON.parse( jsonStr );

Related free learning recommendations: javascript video tutorial

The above is the detailed content of How to convert json to array in javascript. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn