// 예제 데이터 예시 var jsonExample = { “name”: “John Doe”, “age”: 25, “email”: “johndoe@example.com”, “address”: { “street”: “123 Main Street”, “city”: “Somewhere”, “state”: “NY”, “zip”: “12345” }, “hobbies”: [“reading”, “running”, “painting”], “isStudent”: true }; ```
The above code snippet represents an example of JavaScript JSON-formatted data. JSON (JavaScript Object Notation) is a lightweight data interchange format that is easy for humans to read and write, and easy for machines to parse and generate.
In this example, we have a JavaScript object called jsonExample
that contains various properties and values. Let’s break it down:
- The property
name
has a value of “John Doe”, representing the name of a person. - The property
age
has a value of 25, indicating the age of the person. - The property
email
has a value of “johndoe@example.com”, which is the person’s email address. - The property
address
is an object that contains sub-properties likestreet
,city
,state
, andzip
. It represents the person’s address. - The property
hobbies
is an array that contains multiple values, such as “reading”, “running”, and “painting”. These values represent the person’s hobbies. - The property
isStudent
is a Boolean value (true
), which indicates whether the person is a student or not.
JSON data is commonly used for sending and receiving data between a server and a web application. It is also used for storing and transporting data, as it provides a convenient way to structure and organize information in a human-readable format.
In JavaScript, you can parse JSON data using the JSON.parse()
method to convert it into a JavaScript object. Similarly, you can convert a JavaScript object into a JSON string using the JSON.stringify()
method.
JSON has become a standard way of presenting data in various web-related technologies, and it is widely supported by different programming languages and frameworks.