Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the relationship between the object of javascript and json

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of "what is the relationship between the object of javascript and json". The editor shows you the operation process through an actual case. The method of operation is simple and fast, and it is practical. I hope this article "what is the relationship between javascript object and json" can help you solve the problem.

The relationship between the JavaScript object and JSON is that JSON is a string representation of the JavaScript object. JSON uses text to represent a JavaScript object information, which is essentially a string, which can be converted from a JSON string to a js object using the "JSON.parse ()" method.

The operating environment of this tutorial: windows10 system, javascript1.8.5 version, Dell G3 computer.

What is the relationship between javascript object and json

JSON is a string representation of a JS object, which uses text to represent the information of a JS object, which is essentially a string.

Such as

Var``obj = {a: ``'Hello' ``, b:``' World'``}; ``/ / this is an object. Note that the key name is also var```json =`` {"a": "Hello", "b": "World"} ``;`` / / this is a JSON string, which is essentially a string.

JSON and JS objects convert to each other

To convert from a JSON string to a JS object, use the JSON.parse () method:

Var``obj = JSON.parse (``'{"a": "Hello", "b": "World"} '```); ``/ / the result is {a:' Hello', b: 'World'}

To convert from a JS object to a JSON string, use the JSON.stringify () method:

Var`` json = JSON.stringify ({a: ``'Hello'``, b: ``' World'``}); ``/ / the result is'{"a": "Hello", "b": "World"} 'this is the end of the content about "what is the relationship between javascript objects and json". Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 262

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report