RE: RE: JavaScript开发笔记
You are viewing a single comment's thread from:

RE: JavaScript开发笔记

Words
87
Reading
1 min
Listen
Play
7M

JSON 格式(JavaScript Object Notation 的缩写)是一种用于数据交换的文本格式.
JSON 的常规用途是同 web 服务器进行数据交换。在向 web 服务器发送数据时,数据必须是字符串。
通过 JSON.stringify() 把 JavaScript 对象转换为字符串。
参考
在线检查工具

["one", "two", "three"]
{ "one": 1, "two": 2, "three": 3 }
{"names": ["张三", "李四"] }
[ { "name": "张三"}, {"name": "李四"} ]
{
    "title": title,
    "author": author,
    "permlink": permlink,
    "body": body,
    "created": new Date(),
    "json_metadata": jsonMetadata
}

JSON JavaScript  JSON JSON.stringify()JSON.parse()

JSON.stringify
 JSON JSON.parse
  JSON.stringify({ name: "张三" })
  // '{"name":"张三"}'

JSON.parse
  JSON.parse('[1, 5, "false"]') // [1, 5, "false"]
  JSON.parse('null') // null
  var o = JSON.parse('{"name": "张三"}');
  o.name // 张三

JSON.parse

  SyntaxError: Unexpected end of JSON input at JSON.parse (<anonymous>)
JSON.parse
if(item.json_metadata !== ''){
   let json = JSON.parse(item.json_metadata)

@lemooljiang: JSON 格式(JavaScript | Ecency