JSON

作者: CHENpq | 来源:发表于2019-05-05 23:59 被阅读0次

    JSON

    Object

    enclosed within braces, { }

    – Example: { "name": "html", "years": 5 }

    Array

    enclosed within brackets, [ ]

    – Example:

    • [{“name":"Jo","email":"a@b.com"}, {“name":"Jo","email":"a@b.com"}]

    JSON syntax

    value

    A value can be: A string, a number, true, false, null, an object, or an array

    – Values can be nested

    number

    All numbers are decimal--no octal or hexadecimal

    JSON & XML

    similarity:

    – Both are human readable– Both have very simple syntax– Both are hierarchical– Both are language independent– Both can be used by Ajax– Both supported in APIs of many programming languages

    difference:

    – Syntax is different

    – JSON is less verbose #更简洁

    – JSON can be parsed by JavaScript’s eval() method #解析用

    – JSON includes arrays

    – Names in JSON must not be JavaScript reserved words #避开js关键字

    – XML can be validated

    相关文章

      网友评论

          本文标题:JSON

          本文链接:https://www.haomeiwen.com/subject/ahcloqtx.html