String类型转json 转JSONObject 转 JSONArray 以及 遍历
public PageVo getByPage(int pageNum, int pageSize) {
PageVo pageVo = new PageVo();
System.out.println("web " + pageNum);
System.out.println("web " + pageSize);
List<Map<String, Object>> getCurrentiJDByPage = iSearchService.getCurrentiJDByPage(pageNum, pageSize);
List<Map<String ,Object>> newList =new ArrayList();
for (Map<String, Object> jdMap :getCurrentiJDByPage) {
Map<String, Object> content = (Map) JSON.parse((String) jdMap.get("content"));
Map<String, Object> map = new HashMap<>();
JSONObject obj = (JSONObject) content.get("workExec");
JSONObject education = (JSONObject) content.get("education");
JSONObject position = (JSONObject) content.get("position");
JSONObject monthScale = (JSONObject) content.get("monthScale");
JSONArray welfareArray = (JSONArray) content.get("welfare");
JSONObject skill = (JSONObject)content.get("skill");
for (int i = 0; i < welfareArray.size(); i++) {
JSONObject welfare = welfareArray.getJSONObject(i);
map.put("welfareName"+i, welfare.get("name"));
}
Map<String, String> params = JSONObject.parseObject(obj.toJSONString(), new TypeReference<Map<String, String>>() {
});
Map<String, Object> educationParam = JSONObject.parseObject(education.toJSONString(), new TypeReference<Map<String, Object>>() {
});
Map<String, Object> positionParam = JSONObject.parseObject(position.toJSONString(), new TypeReference<Map<String, Object>>() {
});
Map<String, String> monthScaleParam = JSONObject.parseObject(monthScale.toJSONString(), new TypeReference<Map<String, String>>() {
});
Map<String, String> skillParam = JSONObject.parseObject(skill.toJSONString(), new TypeReference<Map<String, String>>() {
});
String database = skillParam.get("database");
String devEnvironment = skillParam.get("devEnvironment");
String devFrame = skillParam.get("devFrame");
String importantDto = skillParam.get("importantDto"); JSONObject important = (JSONObject)JSONObject.parse(importantDto);
JSONArray devLanguage = (JSONArray) important.get("devLanguage");
JSONArray modelAlgo = (JSONArray) important.get("modelAlgo"); JSONArray parse = (JSONArray)JSONArray.parse(database);
JSONArray environment = (JSONArray)JSONArray.parse(devEnvironment);
JSONArray frame = (JSONArray)JSONArray.parse(devFrame);
for (int i = 0; i < environment.size(); i++) {
JSONObject json = environment.getJSONObject(i);
map.put("devEnvironment"+i, json.get("name"));
}
for (int i = 0; i < devLanguage.size(); i++) {
JSONObject json = devLanguage.getJSONObject(i); // 遍历 jsonarray 数组,把每一个对象转成 json 对象
map.put("devLanguage"+i, json.get("name"));
}
for (int i = 0; i < modelAlgo.size(); i++) {
JSONObject json = modelAlgo.getJSONObject(i); // 遍历 jsonarray 数组,把每一个对象转成 json 对象
map.put("modelAlgo"+i, json.get("name"));
}
for (int i = 0; i < frame.size(); i++) {
JSONObject json = frame.getJSONObject(i);
map.put("frame"+i, json.get("name"));
}
for (int i = 0; i < parse.size(); i++) {
JSONObject json = parse.getJSONObject(i);
map.put("database"+i, json.get("name"));
} Integer peopleSize = (Integer)jdMap.get("people_size");
Integer financeStep = (Integer)jdMap.get("finance_step");
switch (financeStep){
case 0 :
map.put("financeStep", ResumeScaleEnum.UNLIMITED.getMessage());
break;
case 1 :
map.put("financeStep", ResumeScaleEnum.PRE_A.getMessage());
break;
case 2 :
map.put("financeStep", ResumeScaleEnum.PRE_B.getMessage());
break;
case 3 :
map.put("financeStep", ResumeScaleEnum.PRE_C.getMessage());
break;
case 4 :
map.put("financeStep", ResumeScaleEnum.PRE_D.getMessage());
break;
case 5 :
map.put("financeStep", ResumeScaleEnum.PRE_ANGEL.getMessage());
break;
case 6 :
map.put("financeStep", ResumeScaleEnum.UN_FINANCE.getMessage());
break;
case 7 :
map.put("financeStep", ResumeScaleEnum.LISTED.getMessage());
break;
case 8 :
map.put("financeStep", ResumeScaleEnum.PRE_D_ABOVE.getMessage());
break;
}
switch (peopleSize){
case 0 :
map.put("peopleSize", ResumePeopleSizeEnum.UNLIMITED.getMessage());
break;
case 1 :
map.put("peopleSize", ResumePeopleSizeEnum.ONE.getMessage());
break;
case 2 :
map.put("peopleSize", ResumePeopleSizeEnum.TWO.getMessage());
break;
case 3 :
map.put("peopleSize", ResumePeopleSizeEnum.THREE.getMessage());
break;
case 4 :
map.put("peopleSize", ResumePeopleSizeEnum.FOUR.getMessage());
break;
case 5 :
map.put("peopleSize", ResumePeopleSizeEnum.FIVE.getMessage());
break;
}
String industryIds = (String) jdMap.get("industry_ids");
String[] industryIdsArr = industryIds.split(",");
String str = "";
if (industryIdsArr != null && industryIdsArr.length > 0) {
for (int i = 0; i < industryIdsArr.length; i++) {
Industry industry = resumeService.getIndustryById(industryIdsArr[i]);
str += industry.getName() + ",";
}
}
str = str.substring(0, str.length() - 1);
map.put("industryName",str);
map.put("id",jdMap.get("id"));
map.put("logoUrl", jdMap.get("logo_url"));
map.put("name", jdMap.get("name"));
map.put("companyId", jdMap.get("company_id"));
map.put("workAddress", content.get("workAddress"));
map.put("workExec", params.get("name"));
map.put("education", educationParam.get("name"));
map.put("position", positionParam.get("name"));
map.put("monthScaleSmall", monthScaleParam.get("small"));
map.put("monthScaleBig", monthScaleParam.get("big"));
newList.add(map);
}
pageVo.setList(newList);
pageVo.setPs(pageSize);
pageVo.setPn(pageNum);
return pageVo;
}
String类型转json 转JSONObject 转 JSONArray 以及 遍历的更多相关文章
- 将String类型的json数据转换为真正的json数据
问题 在做JavaWeb项目的时候,我们经常需要将Java对象转化为Json数据格式响应到前台页面,但是转化完成之后,看着是Json类型的数据格式,但实际上是字符串类型,在这里说两个方法将String ...
- 工具请求接口参数为string类型的JSON字符串时需要加转义字符模拟测试
例如postMan传String类型的json字符串请后台接口时,需要\转义
- json:JSONObject与JSONArray的使用
1.JAR包简介 要使程序可以运行必须引入JSON-lib包,JSON-lib包同时依赖于以下的JAR包: commons-lang.jar commons-beanutils.jar commons ...
- 将String类型的json字符串转换成java对象
1,import com.fasterxml.jackson.databind.ObjectMapper; ObjectMapper mapper = new ObjectMapper(); Mycl ...
- fastjson对json字符串JSONObject和JSONArray互相转换操作示例
2017-03-25 直接上代码: package com.tapt.instance; import com.alibaba.fastjson.JSON; import com.alibaba.fa ...
- 前端String类型转JSON类型
在js中通过ajax获取数据后,赋值给前端树形插件zTree中的zNodes,但一直失败如图: 浏览器端报错: 于是我将zNodes变量的值直接写死,并打印这两个的值,如图 再次运行成功.浏览器控制台 ...
- java解析复杂json:JSONObject 和 JSONArray的使用
在正式解析之前,我们需要下载解析Json所需要的jar包,一共有7个. 下载地址如下:https://download.csdn.net/download/zai_xia/10374080 大家也可以 ...
- json、JSONObject、JSONArray的应用
type.java package jiekou.duixiang; import java.text.ParseException;import java.text.SimpleDateFormat ...
- 011-JSON、JSONObject、JSONArray使用、JSON数组形式字符串转换为List<Map<String,String>>的8种方法
一.JSON数据格式 1.1.常用JSON数据格式 1.对象方式:JSONObject的数据是用 { } 来表示的, 例如: { "id" : "123", & ...
随机推荐
- asxios--form data提交,setcookie
React native 项目,部分接口用form data 提交,以及在Android端,虽然设置了请求携带cookie,但每次请求携带的cookie跟初始化时都不一样,目前做法是去到初始化中返回的 ...
- Java的HashMap是如何实现的?
以下内容转自:http://blog.csdn.net/vking_wang/article/details/14166593 1. HashMap的数据结构 数据结构中有数组和链表来实现对数据的存储 ...
- Python 全栈开发十一 深浅拷贝
深浅拷贝 深浅拷贝的前提: 相等和相同的关系 深浅拷贝针对的是列表等可变的数据类型. 深浅拷贝在普通的列表没有什么意义,只有在嵌套列表,或其他嵌套数据类型才有意义. a = "aaa&quo ...
- 使用MySQL的mysqldump命令备份数据库和把数据库备份文件恢复
1,备份数据库 mysql -uroot -p123456 db_name > /root/db_name.dump 2,数据库备份文件恢复 mysql -uroot -p123456 db_n ...
- 实验一Java开发环境的熟悉-3
实现学生成绩管理功能(增删改,排序,查找),并进行测试(正常情况,异常情况,边界情况). 代码:
- leetcode 343 整数拆分
1.这个题拿到之后没有什么思路,此时就应该考虑暴力法.然而每次不知道要拆成几份,没办法用循环,所以想到用递归. 如图所示进行递归,显然有很多重复的计算,所以用自底向上的动态规划. 2.还有一个问题就是 ...
- .Net拾忆:从List去除重复-拾忆集合
方法1: private static List<int> DistinctList(List<int> list) {//去除重复 HashSet<int> ha ...
- iOS 正则表达式(一)
在iOS开发中,正则一直是最常用的,但也是一直记不住的,现在做一些简单的总结 我们在网上找的正则,要有'\',这个在iOS是转义符,需要'\\'这样 int main(int argc, const ...
- OEMCC13.2 添加监控目标
1.需求描述 2.添加数据库目标 2.1 部署AGENT 2.1.1 直接安装方式 2.1.2 离线安装方式 2.1.3 命令行安装方式 2.2 添加集群资源 2.3 添加数据库 3.添加 ...
- Hibernate.编写xml文件无自动提示信息
Hibernate.编写xml文件无自动提示信息 注意: 配置 xxxx.hbm.xml 文件的自动提示.和配置 hibernate.cfg.xml 文件的提示,操作步骤是一样的.只是复制的文件内容. ...