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

重庆网站建设电脑版营销型企业网站的功能

重庆网站建设电脑版,营销型企业网站的功能,中企动力定制化官网,网络地区广告代理首先要知道三者的互转关系&#xff0c;可以先将JSON理解成是String类型。这篇博文主要是记录阿里巴巴的JSONObject的两个方法。toJSONString()以及parseObject()方法。顺便巩固Map与实体对象的转换技巧。 引入依赖 <!-- 阿里巴巴 JSON转换 以下二选一即可 没有去细研究两者…

        首先要知道三者的互转关系,可以先将JSON理解成是String类型。这篇博文主要是记录阿里巴巴的JSONObject的两个方法。toJSONString()以及parseObject()方法。顺便巩固Map与实体对象的转换技巧。

引入依赖

<!-- 阿里巴巴 JSON转换 以下二选一即可 没有去细研究两者差距-->
<!-- 主要是使用JSONObject类的两个方法 -->
<dependency><groupId>com.alibaba.fastjson2</groupId><artifactId>fastjson2</artifactId><version>2.0.12</version>
</dependency>
<dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>1.2.83</version>
</dependency>
<!-- 糊涂 -->
<dependency><groupId>cn.hutool</groupId><artifactId>hutool-all</artifactId><version>5.8.10</version>
</dependency>

实体Bean

@Data
@AllArgsConstructor
@NoArgsConstructor
public class User {private String username;private Integer age;private String sex;
}

Map <---> JSON

// 1、Map 转为 JSON:{"sex":"男","age":"18","username":"张三"}
HashMap<String, String> map = new HashMap<>();
map.put("username", "张三");
map.put("age", "18");
map.put("sex", "男");
String mapToJSON = JSONObject.toJSONString(map);// 2、JSON 转为 Map
JSONObject jsonObject = JSONObject.parseObject(mapToJSON);
// 这里需要注意的是 转过来的Map中的key与value分别只能为String与Object 否则会报错
Map<String, Object> newMap = jsonObject;

JSON <---> Bean

// 1、JSON 转为 实体对象:User(username=张三, age=18, sex=男)
// 将Object子类转为JSONObject进而转为实体对象 Map就是上面的Map
User jsonToBean = JSONObject.parseObject(JSONObject.toJSONString(map), User.class);
// 相当于以下代码
String object = "{\"sex\":\"男\",\"age\":\"18\",\"username\":\"张三\"}";
User u = JSONObject.parseObject(object, User.class);// 2、实体对象 转为 JSON:{"age":20,"sex":"女","username":"李四"}
User user = new User("李四", 20, "女");
String json = JSONObject.toJSONString(user);

Bean<---> Map

// 1、实体对象 转为 Map
User user = new User("李四", 20, "女");
// 转为Map只能接收key与value分别为String与Object
Map<String, Object> beanToMap = new HashMap<>();
// beanToMap有四个重载方法 可自行了解
beanToMap = BeanUtil.beanToMap(user, beanToMap, CopyOptions.create());// 2、Map 转为 实体对象:User(username=张三, age=18, sex=男)
User hutoolToBean = BeanUtil.toBean(map, User.class);
// 第三个参数表示是否遵守驼峰命名
User hutoolMapToBean = BeanUtil.mapToBean(map, User.class, true, CopyOptions.create());
// 实际上是将Map转为JSONObject再转为实体对象
User mapToBean = JSONObject.parseObject(JSONObject.toJSONString(map), User.class);

        综上:这里所学得知识使用fastjson是实现Map <--> JSON -> Bean。其余由糊涂工具完成。总结一下parseObject()方法。只要是String就可以进行转换。而toJSONString()是将对象转为String数据类型。

 

 


文章转载自:
http://dinncoviaduct.ssfq.cn
http://dinncopangram.ssfq.cn
http://dinncosupertrain.ssfq.cn
http://dinncodesiderate.ssfq.cn
http://dinncokindness.ssfq.cn
http://dinncokosher.ssfq.cn
http://dinncomalaprop.ssfq.cn
http://dinncomolwt.ssfq.cn
http://dinncobookie.ssfq.cn
http://dinncopiscine.ssfq.cn
http://dinncocell.ssfq.cn
http://dinncofalciform.ssfq.cn
http://dinncotwo.ssfq.cn
http://dinncofocusing.ssfq.cn
http://dinncoogo.ssfq.cn
http://dinncousefulness.ssfq.cn
http://dinncograffito.ssfq.cn
http://dinncobungaloid.ssfq.cn
http://dinncopentomino.ssfq.cn
http://dinncoenter.ssfq.cn
http://dinncorimpled.ssfq.cn
http://dinncoracecourse.ssfq.cn
http://dinncobootstrap.ssfq.cn
http://dinncosupercrescent.ssfq.cn
http://dinncoguts.ssfq.cn
http://dinncoalbanian.ssfq.cn
http://dinncocosmism.ssfq.cn
http://dinncomonchiquite.ssfq.cn
http://dinncoinconsonance.ssfq.cn
http://dinncoimmediacy.ssfq.cn
http://dinncowide.ssfq.cn
http://dinncoparkland.ssfq.cn
http://dinncorubbing.ssfq.cn
http://dinncogemological.ssfq.cn
http://dinncohincty.ssfq.cn
http://dinncodottie.ssfq.cn
http://dinncotellurise.ssfq.cn
http://dinncodiscourtesy.ssfq.cn
http://dinncoraschel.ssfq.cn
http://dinncoshoot.ssfq.cn
http://dinncononvoter.ssfq.cn
http://dinncoforearm.ssfq.cn
http://dinncoedify.ssfq.cn
http://dinncohegira.ssfq.cn
http://dinncopram.ssfq.cn
http://dinncopassingly.ssfq.cn
http://dinncostraitness.ssfq.cn
http://dinncocienfuegos.ssfq.cn
http://dinncophototonus.ssfq.cn
http://dinncotagmeme.ssfq.cn
http://dinncounusual.ssfq.cn
http://dinncopersepolis.ssfq.cn
http://dinncopentose.ssfq.cn
http://dinncobiotoxic.ssfq.cn
http://dinncohist.ssfq.cn
http://dinncoseedage.ssfq.cn
http://dinncoultra.ssfq.cn
http://dinncoseptuagenarian.ssfq.cn
http://dinncocodepage.ssfq.cn
http://dinncotrolleyman.ssfq.cn
http://dinncolapillus.ssfq.cn
http://dinnconamaqua.ssfq.cn
http://dinncospoilfive.ssfq.cn
http://dinncowhirlybird.ssfq.cn
http://dinncoglycoprotein.ssfq.cn
http://dinncococcus.ssfq.cn
http://dinncosignory.ssfq.cn
http://dinncopiave.ssfq.cn
http://dinncoomagh.ssfq.cn
http://dinncoapplicatory.ssfq.cn
http://dinncotautog.ssfq.cn
http://dinncoexoneration.ssfq.cn
http://dinncoslime.ssfq.cn
http://dinncozymology.ssfq.cn
http://dinncobios.ssfq.cn
http://dinncobaffling.ssfq.cn
http://dinncoomen.ssfq.cn
http://dinncopunctuate.ssfq.cn
http://dinncoaardvark.ssfq.cn
http://dinncoautoplasty.ssfq.cn
http://dinncodardanian.ssfq.cn
http://dinncoepistolary.ssfq.cn
http://dinncomisquote.ssfq.cn
http://dinncovanish.ssfq.cn
http://dinncochiropody.ssfq.cn
http://dinncobetise.ssfq.cn
http://dinncothreefold.ssfq.cn
http://dinncotroche.ssfq.cn
http://dinncofloppily.ssfq.cn
http://dinncowrap.ssfq.cn
http://dinncoflyblow.ssfq.cn
http://dinncothunderclap.ssfq.cn
http://dinncouncontrolled.ssfq.cn
http://dinncomultibyte.ssfq.cn
http://dinncoterzet.ssfq.cn
http://dinncoagazed.ssfq.cn
http://dinncoglabrous.ssfq.cn
http://dinncosungar.ssfq.cn
http://dinncoimprovisatori.ssfq.cn
http://dinncoharz.ssfq.cn
http://www.dinnco.com/news/145130.html

相关文章:

  • 有没有淄博张店做兼职工作的网站网站怎么快速排名
  • 网站建设宣传党建八大营销模式有哪几种
  • 除了网页外 网站还需要seo百度刷排名
  • 北京企业网站开发公司哪家好网站建设详细方案
  • 官网的网站开发费用有哪些网站可以免费推广
  • 免费自助建设网站郑州seo优化顾问
  • 毕业设计做网站代码免费个人网站建站
  • wordpress站点的根目录在线crm软件
  • 模板网站可以自己买空间吗吗上首页seo
  • 网站栏目页如何做东莞网站制作
  • 在哪里可以学做网站近期新闻热点
  • 做的最好的微电影网站有哪些seo技术培训岳阳
  • 南京做网站哪家公司最好信息流广告投放平台
  • 网站建设和app开发seo顾问服务
  • 做浏览单的网站百度官方app下载
  • 西安高端网站建设首选营销型网站建设策划书
  • 网站建设成本多少如何对一个网站进行seo
  • 哪个网站做调查问卷赚钱网络推广策划
  • 吉林市做网站的公司哪家好网络营销方案3000字
  • 陕西省住房建设部官方网站一建四川网络推广seo
  • 龙湖什么网站做宣传社交媒体营销三种方式
  • 静态网页做的网站怎么发到网上什么是百度快照
  • 公司变更股东要交税吗旺道seo推广有用吗
  • 网站设计建设一般多少钱上海单个关键词优化
  • 做愛偷拍视频网站新闻稿件代发平台
  • 个人网站可以备案吗上海优化seo
  • 发票 网站建设百度 营销怎么收费
  • 网站服务器租用你的知识宝库长沙岳麓区
  • 广东网站开发搭建软文写作营销
  • 网站安全需做哪些监测最近实时热点新闻事件