Blogger Information
Blog 42
fans 0
comment 0
visits 15672
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
0729Json常用api
小言
Original
334 people have browsed it

1、json属于文本,可以将任何js对象转为json,然后将json传递到服务器

2、所有服务器数据都可以作为json转为js对象

3、我们也可以把数据作为js对象来处理,支持任何语言,不受限制

4、可以实现前后端数据都通过json进行交互

Js转json
  1. const user = {
  2. id:1,
  3. name:'测试',
  4. price:100,
  5. };
  6. console.log(user);
  7. let json = JSON.stringify(user);
  8. console.log(json);

Json转js
  1. let str = `{
  2. "id": 1,
  3. "name": "测试",
  4. "price": 100
  5. }`;
  6. let item = JSON.parse(str);
  7. console.log(item);

Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post