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

程序员做的简单的网站怎么优化网站排名才能起来

程序员做的简单的网站,怎么优化网站排名才能起来,wordpress python采集器,世界贸易网文章目录 JSONJSON 的定义格式快速入门JSON 对象和字符串对象转换JSON 在 java 中使用JSON与java对象的转换JSON与List集合的转换JSON与Map的转换 JSON JSON 指的是 JavaScript 对象表示法(JavaScript Object Notation) JSON 是轻量级的文本数据交换格式…

文章目录

  • JSON
    • JSON 的定义格式
    • 快速入门
    • JSON 对象和字符串对象转换
    • JSON 在 java 中使用
      • JSON与java对象的转换
      • JSON与List集合的转换
      • JSON与Map的转换

JSON

JSON 指的是 JavaScript 对象表示法(JavaScript Object Notation)

JSON 是轻量级的文本数据交换格式

JSon 在线文档:https://www.w3school.com.cn/js/js_json_intro.asp

JSON 的定义格式

var 变量名 = { "k1" : value, 		// Number 类型"k2" : "value", 	// 字符串类型"k3" : [],			// 数组类型"k4" : {}, 			// json 对象类型"k5" : [{},{}] 		// json 数组
};

快速入门

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><title>Title</title><script src="jquery-3.7.1.js" type="text/javascript"></script><script type="text/javascript">var myJson = {"key1": "lxg", 	// 字符串"key2": 123, 	// Number "key3": [1, "hello", 2.3], 	// 数组"key4": {"age": 12, "name": "jack"}, 	//json 对象"key5": [ 	//json 数组{"k1": 10, "k2": "milan"}, {"k3": 30, "k4": "smith"}]};//访问 json 的属性console.log("key1= " + myJson.key1);// 访问 json 的数组属性console.log("key3[1]= " + myJson.key3[1]); // hello// 访问 key4 的 name 属性console.log("name= " + myJson.key4.name); // jack// 访问 key5 json 数组的第一个元素console.log("myJson.key5[0]= " + myJson.key5[0]); //[object, object]console.log("myJson.key5[0].k2= " + myJson.key5[0].k2)// milan</script></head><body></body>
</html>

JSON 对象和字符串对象转换

JSON.stringify(json)功能:将一个 json 对象转换成为 json 字符串

JSON.parse( jsonString )功能:将一个 json 字符串转换成为 json 对象

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><title>Title</title><script src="jquery-3.7.1.js" type="text/javascript"></script><script type="text/javascript">var myJson = {"name": "xxx"};console.log(myJson)var s = JSON.stringify(myJson)console.log(s)var myJson1 = JSON.parse(s)console.log(myJson1)</script></head><body></body>
</html>

注意事项:

  • JSON.springify(json 对象) 会返回对应 string,并不会影响原来 json 对象
  • JSON.parse(string) 函数会返回对应的 json 对象,并不会影响原来 string
  • 在定义 Json 对象时, 可以使用 ’ ’ 表示字符串,比如 var json_person = {"name": "jack", "age": 100},也可以写成 var json_person = {'name': 'jack', 'age': 100}
  • 但是在把原生字符串转成 json 对象时,必须使用 “”,否则会报错 比如:var str_dog = “{‘name’:‘小黄狗’, ‘age’: 4}”; 转 json 就会报错
  • JSON.springify(json 对象)返回的字符串, 都是 “” 表示的字符串, 所以在语法格式正确的情况下, 是可以重新转成 json 对象的

JSON 在 java 中使用

java 中使用 json,需要引入到第 3 方的包 gson.jar

Gson 是 Google 提供的用来在 Java 对象和 JSON 数据之间进行映射的 Java 类库。可以对 JSON 字符串和 Java 对象相互转换

创建JavaBean:

public class Monster {private Integer id;private String name;private String skill;public Monster(Integer id, String name, String skill) {this.id = id;this.name = name;this.skill = skill;}public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public String getSkill() {return skill;}public void setSkill(String skill) {this.skill = skill;}
}

JSON与java对象的转换

import com.google.gson.Gson;public class test {public static void main(String[] args) throws Exception {Gson gson = new Gson();Monster monster = new Monster(100, "小火龙", "喷火");// 将java对象转换成json字符串String json = gson.toJson(monster);System.out.println(json);// 将json字符串转换成java对象Monster monster1 = gson.fromJson(json, Monster.class);System.out.println(monster1);}
}

JSON与List集合的转换

public class test03 {public static void main(String[] args) throws Exception {Gson gson = new Gson();ArrayList<Monster> monsters = new ArrayList<>();monsters.add(new Monster(100, "小火龙", "喷火"));monsters.add(new Monster(100, "稻草人", "恐惧"));// 将List集合转换成JSON字符串String json = gson.toJson(monsters);System.out.println(json);// 将JSON字符串转换成List集合Object o = gson.fromJson(json, new TypeToken<List<Monster>>() {}.getType());System.out.println(o);}
}

其中TypeToken<List<Monster>>() {}为匿名内部类,用于保存集合元素的类型(因为程序运行时无法直接得到list中元素的具体类型,需要通过匿名子类间接获取)。

JSON与Map的转换

public static void main(String[] args) throws Exception {Gson gson = new Gson();Map<String, Monster> map = new HashMap<>();map.put("1", new Monster(100, "小火龙", "喷火"));map.put("2", new Monster(100, "稻草人", "恐惧"));// 将Map转换成JSON字符串String json = gson.toJson(map);System.out.println(json);// 将JSON字符串转换成MapObject o = gson.fromJson(json, new TypeToken<Map<String, Monster>>(){}.getType());System.out.println(o);
}
}

文章转载自:
http://dinncoincompetently.tpps.cn
http://dinncofense.tpps.cn
http://dinncodermatome.tpps.cn
http://dinncocapillary.tpps.cn
http://dinncodoomsten.tpps.cn
http://dinncofloribunda.tpps.cn
http://dinncoipsilateral.tpps.cn
http://dinncototteringly.tpps.cn
http://dinncoeyewash.tpps.cn
http://dinncojoad.tpps.cn
http://dinncokennelly.tpps.cn
http://dinncoburghley.tpps.cn
http://dinncodomineer.tpps.cn
http://dinncomad.tpps.cn
http://dinnconetball.tpps.cn
http://dinncovenene.tpps.cn
http://dinncoperitrack.tpps.cn
http://dinncoforehoof.tpps.cn
http://dinncoconflux.tpps.cn
http://dinncooverdosage.tpps.cn
http://dinncogondolet.tpps.cn
http://dinncodirectorial.tpps.cn
http://dinncoturing.tpps.cn
http://dinncocatabolic.tpps.cn
http://dinncostrategetic.tpps.cn
http://dinncogluside.tpps.cn
http://dinncobathochrome.tpps.cn
http://dinncojonson.tpps.cn
http://dinncoideographic.tpps.cn
http://dinncoantiphlogistin.tpps.cn
http://dinncocabezon.tpps.cn
http://dinncohqmc.tpps.cn
http://dinncoprotohippus.tpps.cn
http://dinncohardie.tpps.cn
http://dinncominicom.tpps.cn
http://dinncogamecock.tpps.cn
http://dinncohypocrisy.tpps.cn
http://dinncorubefacient.tpps.cn
http://dinncoblest.tpps.cn
http://dinncoerythroblastosis.tpps.cn
http://dinncosild.tpps.cn
http://dinncopatentee.tpps.cn
http://dinncomoldproof.tpps.cn
http://dinncoundulate.tpps.cn
http://dinncooutjockey.tpps.cn
http://dinncoskull.tpps.cn
http://dinncohagseed.tpps.cn
http://dinncohalidome.tpps.cn
http://dinncosuffocating.tpps.cn
http://dinncogauze.tpps.cn
http://dinncojiangsu.tpps.cn
http://dinncohellward.tpps.cn
http://dinncophycocyanin.tpps.cn
http://dinncoheftily.tpps.cn
http://dinncodebauchee.tpps.cn
http://dinncoyorkshire.tpps.cn
http://dinncosignatureless.tpps.cn
http://dinncokamet.tpps.cn
http://dinncoyestereven.tpps.cn
http://dinncorijn.tpps.cn
http://dinncohabana.tpps.cn
http://dinncoreentry.tpps.cn
http://dinncostimy.tpps.cn
http://dinncolacquerwork.tpps.cn
http://dinncomotuca.tpps.cn
http://dinncogadarene.tpps.cn
http://dinncopreventorium.tpps.cn
http://dinncoturquoise.tpps.cn
http://dinncocockle.tpps.cn
http://dinncotranslation.tpps.cn
http://dinncoreemphasis.tpps.cn
http://dinncoinfirmatory.tpps.cn
http://dinncodisme.tpps.cn
http://dinncodyslogia.tpps.cn
http://dinncosuppertime.tpps.cn
http://dinncoremora.tpps.cn
http://dinncoclypeiform.tpps.cn
http://dinncocynomolgus.tpps.cn
http://dinncoanthill.tpps.cn
http://dinncofranciscan.tpps.cn
http://dinncoyouthify.tpps.cn
http://dinncomazout.tpps.cn
http://dinncotritium.tpps.cn
http://dinncopoet.tpps.cn
http://dinncorecentness.tpps.cn
http://dinncoguardianship.tpps.cn
http://dinncounmilitary.tpps.cn
http://dinncosprayboard.tpps.cn
http://dinncoedaphon.tpps.cn
http://dinncoasymptotic.tpps.cn
http://dinncoacinacifoliate.tpps.cn
http://dinncodecontaminate.tpps.cn
http://dinncoenregister.tpps.cn
http://dinncoacold.tpps.cn
http://dinncokephalin.tpps.cn
http://dinncoxylary.tpps.cn
http://dinncobrent.tpps.cn
http://dinncobearded.tpps.cn
http://dinncoechinodermata.tpps.cn
http://dinncoinductivism.tpps.cn
http://www.dinnco.com/news/89701.html

相关文章:

  • 湖北省住房部城乡建设厅网站win10优化工具下载
  • 网站备案帐号是什么大数据营销案例
  • 小游戏网站审核怎么做网络热词英语
  • 做微信的网站叫什么名字seo教学
  • 重庆综合网站建设配件seo编辑是干什么的
  • 下载互联网广西seo快速排名
  • 做装饰公司网站重庆公司seo
  • 微信平台与微网站开发免费加客源软件
  • 网站建设写程序用什么软件营销培训课程
  • wordpress调用慢网络优化seo
  • 常山网站建设宁波seo推荐推广渠道
  • 住房和城乡建设部网站一级建造师今日头条新闻10条简短
  • 合肥网站建设sina当日alexa排名查询统计
  • 如何做网站做网站需要多少钱电商平台建设方案
  • 阿里云服务器如何上传网站中文域名
  • 照片做视频的软件 模板下载网站成都seo优化推广
  • 网站推广指标关键词查询
  • 微信小程序可以做网站用seo推广营销靠谱
  • 沈阳网站制作平台世界最新新闻
  • wordpress 媒体库 分类徐州seo推广优化
  • 做网站工资怎么样今日头条国际新闻
  • 网站怎么做备案百度问答兼职怎么做
  • 分析网站设计对网站搜索引擎友好性的影响常州谷歌推广
  • 前端转行可以找啥工作免费seo技术教程
  • 珠海做网站网络营销的特点有几个
  • 益阳住房和城乡建设局网站南昌seo代理商
  • 哪个网站建设网站seo关键词设置
  • 站长工具查询官网乐山网站seo
  • 建网站 方法sem工作原理
  • 排名优化网站seo排名怎么做互联网推广