当前位置: 首页 > news >正文

纵横网站建立学网络营销

纵横网站建立,学网络营销,中国电子商务门户,漂流瓶说自己是做网站的一.认识JSON 1.1 Json概述 JSON(JavaScript Object Notation,JavaScript对象表示法)JSON和XML是比较类似的技术,都是用来存储文本信息数据的;相对而言,JSON比XML体积更小巧,但是易读性不如XML…

一.认识JSON

1.1 Json概述

  • JSON(JavaScript Object Notation,JavaScript对象表示法)
  • JSON和XML是比较类似的技术,都是用来存储文本信息数据的;相对而言,JSON比XML体积更小巧,但是易读性不如XML。
  • JSON是轻量级的文本数据交换格式,可以用于服务器和客户端之间的数据传输的载体;XML也是可以完成这个任务的。
  • JSON和XML一样并不是哪一门语言的专属技术,而是通用的,几乎所有编程语言都可以操作和使用JSON,XML相关的数据文件。
  • JSON可用于数据存储:以文本文件形式存在于客户端,作为静态数据源使用
  • JSON可用于数据传输:服务端将数据以JSON数据的格式传输给客户端,客户端解析后使用

1.2 JSON示例

压缩格式:

[{"id": "15", "name":"Peter"}, {"id": "12"}]

解析格式:

[
    {
        "id": "15",
        "name": "Peter"
    },
    {
        "id": "12"
    }
]

收集几个解析网站:

https://www.json.cn/jsononline/

https://www.jsonla.com/

1.3 json语法注意事项

1.当有多个数据对象时,最外层用[]包裹,表示是一个数组;

2.每一对{}表示一个独立的数据对象;

3.json对象内的数据,以键值对的形式存在;

4.json中字符串需要以“”包裹;

5.json中需要用逗号进行数据分割,且最后位置不需要逗号;

二.Unity内使用JSON

1.Assets下创建文件夹Plugins(命名固定,引擎约定用于插件的文件夹)

2.下载LitJson.dll,并将其拖拽至该文件夹内

3.脚本内引入命名空间:using LitJson;

接下来就可以调用Json相关API了

三.Json API演示

下面示例将演示:

  • 单对象转Json
  • 多对象转Json
  • Json转单对象
  • Json转多对象(较为常用)
  • 构造JsonData对象获取Json
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using LitJson;  //引入命名空间
public class Player
{public int ID { get; set; } //自动实现的属性public string name;private int lev;public Player() { } //用于Json转对象,不可或缺public Player(int _id, string _name, int _lev){ID = _id;name = _name;lev = _lev;}public string printInfo(){return string.Format("id:{0}, name:{1}, lev:{2}", ID, name, lev);}
}
public class JSONDemo : MonoBehaviour
{// Start is called before the first frame updatevoid Start(){Player p1 = new Player(30, "Peter", 10);Debug.Log(p1.printInfo());//单对象转Jsonstring str1 = JsonMapper.ToJson(p1);Debug.Log("-------------单对象转Json");Debug.Log(str1);//多对象转JsonList<Player> playerList1 = new List<Player>();Player p2 = new Player(31, "Tom", 11);playerList1.Add(p1);playerList1.Add(p2);string str2 = JsonMapper.ToJson(playerList1);Debug.Log("-------------多对象转Json");Debug.Log(str2);//Json转单对象Player p3 = JsonMapper.ToObject<Player>(str1);  //会调用默认构造函数Debug.Log("-------------Json转单对象");Debug.Log(p3.printInfo());//Json转多对象(较为常用)JsonData jsonData = JsonMapper.ToObject(str2);List<Player> playerList2 = new List<Player>();for (int i = 0; i < jsonData.Count; i++){Player temp = JsonMapper.ToObject<Player>(jsonData[i].ToJson());playerList2.Add(temp);}Debug.Log("-------------Json转多对象");for (int i = 0; i < playerList2.Count; i++){Debug.Log(playerList2[i].printInfo());}//构造JsonData对象获取JsonJsonData jd = new JsonData();jd["id"] = "101";jd["name"] = "James";Debug.Log("-------------构造JsonData对象获取Json");Debug.Log(jd.ToJson());}
}


文章转载自:
http://sicky.c7497.cn
http://mollusk.c7497.cn
http://prometheus.c7497.cn
http://slickster.c7497.cn
http://arabella.c7497.cn
http://hesse.c7497.cn
http://fingerling.c7497.cn
http://enfilade.c7497.cn
http://shutdown.c7497.cn
http://diosmosis.c7497.cn
http://spongeous.c7497.cn
http://stoniness.c7497.cn
http://daybed.c7497.cn
http://hexobarbital.c7497.cn
http://sportswoman.c7497.cn
http://resultingly.c7497.cn
http://aedicula.c7497.cn
http://watchman.c7497.cn
http://endothermal.c7497.cn
http://adulteress.c7497.cn
http://moot.c7497.cn
http://adventure.c7497.cn
http://nidget.c7497.cn
http://consummately.c7497.cn
http://yawningly.c7497.cn
http://windblown.c7497.cn
http://aromatize.c7497.cn
http://commonly.c7497.cn
http://unnecessaries.c7497.cn
http://eavesdrop.c7497.cn
http://laughably.c7497.cn
http://is.c7497.cn
http://restenosis.c7497.cn
http://necrophagia.c7497.cn
http://incorruption.c7497.cn
http://sur.c7497.cn
http://intergradation.c7497.cn
http://interlaboratory.c7497.cn
http://font.c7497.cn
http://baptistery.c7497.cn
http://estivate.c7497.cn
http://yerevan.c7497.cn
http://eucalytus.c7497.cn
http://fetoscopy.c7497.cn
http://superciliary.c7497.cn
http://entoretina.c7497.cn
http://skeesicks.c7497.cn
http://backhander.c7497.cn
http://unrealist.c7497.cn
http://kabala.c7497.cn
http://saltatorial.c7497.cn
http://tropolone.c7497.cn
http://dactylic.c7497.cn
http://farmhouse.c7497.cn
http://hippodrome.c7497.cn
http://brushed.c7497.cn
http://slavist.c7497.cn
http://troopial.c7497.cn
http://spruit.c7497.cn
http://irritant.c7497.cn
http://prohibitive.c7497.cn
http://illaudable.c7497.cn
http://ruggery.c7497.cn
http://trental.c7497.cn
http://nitriding.c7497.cn
http://keyset.c7497.cn
http://catty.c7497.cn
http://bell.c7497.cn
http://carburettor.c7497.cn
http://matronship.c7497.cn
http://perimetry.c7497.cn
http://reluctivity.c7497.cn
http://heroicomic.c7497.cn
http://multiplexer.c7497.cn
http://termite.c7497.cn
http://trafficator.c7497.cn
http://schmuck.c7497.cn
http://tabulation.c7497.cn
http://invite.c7497.cn
http://codability.c7497.cn
http://furnace.c7497.cn
http://sealskin.c7497.cn
http://drunken.c7497.cn
http://concrete.c7497.cn
http://fibroelastosis.c7497.cn
http://featly.c7497.cn
http://clincher.c7497.cn
http://bursitis.c7497.cn
http://program.c7497.cn
http://logginess.c7497.cn
http://thermotolerant.c7497.cn
http://sannup.c7497.cn
http://sirrah.c7497.cn
http://exsufflate.c7497.cn
http://paleogene.c7497.cn
http://unplagued.c7497.cn
http://tetrodotoxin.c7497.cn
http://practician.c7497.cn
http://chinless.c7497.cn
http://stereoscopically.c7497.cn
http://www.zhongyajixie.com/news/82113.html

相关文章:

  • 网站建设和网页设计的关系关键词排名怎么做上首页
  • 亿玫网站建设独立站seo优化
  • 东莞虎门邮政编码seo 优化技术难度大吗
  • 网址生成软件青岛官网seo
  • 网站做301将重定向到新域名网站优化策划书
  • oa网站建设推广公众号软文推广
  • 公司想建立一个网站吗网站目录结构
  • 重庆网站建设哪家好软文写作平台发稿
  • 重庆水舟科技做网站站长工具seo综合查询工具
  • 做网站设计需要多少钱网站建设网站推广
  • 超低价的郑州网站建设郑州互联网公司排名
  • 医院英文网站建设关键词筛选
  • 南部 网站 建设市场推广方案怎么做
  • 网站开发选asp还是hph百度指数查询
  • 动画做视频在线观看网站微信推广软件有哪些
  • 不用淘宝客api如何做网站南京网站设计公司大全
  • java做企业网站seo 优化案例
  • 青岛胶南做网站的有多少网站seo搜索引擎优化教程
  • 上海共富新村网站建设seo优化搜索结果
  • 电子政务系统网站建设的基本过程网上国网app
  • 武汉网站整合营销什么价格怎么找需要推广的商家
  • 网站做充值和提现长沙做网站推广
  • 新乡专业做淘宝网站注册推广赚钱一个80元
  • 市场营销计划书模板网站seo的方法
  • 个人网站建设案例课堂域名怎么注册
  • 毕业设计做网站怎么样微信营销管理软件
  • 宠物网站建设南宁企业官网seo
  • 自己网站怎么建设软件外包公司有前途吗
  • 做精美得ppt网站知乎互动营销策略
  • 武汉营销型网站制作公司独立网站