니가 알고 있는 JSON에 관한 모든 것들parse()와 JSON.stringify()
1851 단어 javascriptjson
JSON.stringify()
Transforms a Javascript object to a JSON string.
A common use of JSON is to exchange data to/from a web server.
When sending data to a web server, the data has to be a string.
Convert a JavaScript object into a string withJSON.stringify()
.
예:
JavaScript에 다음과 같은 객체가 있다고 가정합니다.
const student = {
name: "Alex",
age: 20,
email: "[email protected]"
};
const studentStr = JSON.stringify(student);
console.log(studentStr);
{ "name":"Alex", "age":20, "email":"[email protected]"}
문자열화된 JavaScript 배열
It is also possible to stringify JavaScript arrays.
예:
JavaScript에 다음과 같은 객체가 있다고 가정합니다.
const arrName = [ "John", "Peter", "Sally", "Jane" ];
const jsonName = JSON.stringify(arrName);
console.log(jsonName);
["John","Peter","Sally","Jane"]
JSON.해결()
Takes a JSON string and transform it into a Javascript Object.
예:
우리가 웹 서버에서 이 텍스트를 받았다고 상상해 보세요.
우리는 상술한
studentStr
샘플을 채택할 것이다.const jsObject = JSON.stringify(studentStr);
console.log(jsObject);
Object { age: 20, email: "[email protected]", name: "Alex" }
Reference
이 문제에 관하여(니가 알고 있는 JSON에 관한 모든 것들parse()와 JSON.stringify()), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/lourdesyang/everything-you-know-about-json-parse-and-json-stringify-4o43텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)