String类型转json 转JSONObject 转 JSONArray 以及 遍历

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
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;
 }

 

posted @   春眠不觉笑  阅读(10801)  评论(0编辑  收藏  举报
编辑推荐:
· 软件产品开发中常见的10个问题及处理方法
· .NET 原生驾驭 AI 新基建实战系列:向量数据库的应用与畅想
· 从问题排查到源码分析:ActiveMQ消费端频繁日志刷屏的秘密
· 一次Java后端服务间歇性响应慢的问题排查记录
· dotnet 源代码生成器分析器入门
阅读排行:
· ThreeJs-16智慧城市项目(重磅以及未来发展ai)
· .NET 原生驾驭 AI 新基建实战系列(一):向量数据库的应用与畅想
· Browser-use 详细介绍&使用文档
· 软件产品开发中常见的10个问题及处理方法
· Vite CVE-2025-30208 安全漏洞
点击右上角即可分享
微信分享提示