-
객체가 문자열로 변환
JSON.stringify()
-
객체에 문자열
JSON.parse()
-
예를 들면 :
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <canvas id="canvas"></canvas> <script> let a = [1,2,3]; let a1 = JSON.stringify(a); let a2 = JSON.parse(a1); let b = {'name':'a','age':18}; let b1 = JSON.stringify(b); let b2 = JSON.parse(b1); console.log(a1); console.log(a2); console.log(b1); console.log(b2); </script> </body> </html>
문자열로 자바 스크립트 객체, 객체에 문자열
추천
출처blog.csdn.net/KaiSarH/article/details/104696212
추천
행