zoukankan      html  css  js  c++  java
  • 学习笔记---json和xml区别

    测试web时经常和网页数据打交道,会遇到json格式和xml格式,整理整理,记录下来。

    json最常用的格式是键值对。

    {"firstName": "Brett", "lastName": "McLaughlin"}

    表示数组的时候用   []  。

    json可以将数据转换为字符串,更利于在网络中传输,比xml需要的字节少。但是在数据比较长时,xml看起来更加一目了然。

    xml实例:

    <?xml version="1.0" encoding="utf-8"?>
    <country>
        <name>中国</name>
        <province>
            <name>河北</name>
            <cities>
                <city>保定</city>
                <city>石家庄</city>
            </cities>
        </province>
    </country>

    json实例:

    {
        "name": "中国",
        "province": [{
            "name": "河北",
            "cities": {
                "city": ["保定", "石家庄"]
            }
        }]
    }
  • 相关阅读:
    iOS基础
    iOS基础 ----- 内存管理
    NSAttributedString 的一些基本用法
    node安装使用
    docker常用命令
    docker lnmp
    easy-wechat
    composer
    center7系统搭建lnmp
    xammp环境配置
  • 原文地址:https://www.cnblogs.com/oliver-yt/p/9327573.html
Copyright © 2011-2022 走看看