当前位置:网站首页>Fastjson parses multi-level JSON strings
Fastjson parses multi-level JSON strings
2022-07-28 12:35:00 【When can the dead wood spring】
Json character string :
{
"status":0,"result":{
"location":{
"lng":120.32521556751674,"lat":31.66420355596458},"precise":1,"confidence":75,"comprehension":57,"level":" Building number "}}
Code demonstration :
JSONObject object = JSONObject.parseObject(response).getJSONObject("result").getJSONObject("location");
acc.setAccLng(object.getObject("lng", Double.class));
acc.setAccLat(object.getObject("lat", Double.class));
Complete code :
package com.ruoyi.sc.task;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.sc.domain.ScAcc;
import com.ruoyi.sc.service.IScAccService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import java.util.List;
/** * @Author: xinglibao * @Date: 2022/7/9 22:54 */
@Component("scTask")
public class ScTask {
@Autowired
private IScAccService scAccService;
@Autowired
private RestTemplate restTemplate;
public void scUpdateLng() {
// RestTemplate restTemplate = new RestTemplate();
List<ScAcc> scAccs = scAccService.selectLngIsNull();
for (ScAcc acc : scAccs) {
String url = "https://api.map.baidu.com/geocoding/v3/?address={" + acc.getAccLocation() + "&output=json&ak=tle20HLPKSLCpcUS8XP3IhpR9ZsNL6X1";
// {"status":0,"result":{"location":{"lng":120.32521556751674,"lat":31.66420355596458},"precise":1,"confidence":75,"comprehension":57,"level":" Building number "}}
String response = restTemplate.getForObject(url, String.class);
/*JSONObject jsonObject1 = JSONObject.parseObject(response); String result = jsonObject1.getString("result"); JSONObject jsonObject2 = JSONObject.parseObject(result); String location = jsonObject2.getString("location"); JSONObject jsonObject3 = JSONObject.parseObject(location); acc.setAccLng(jsonObject3.getObject("lng", Double.class)); acc.setAccLat(jsonObject3.getObject("lat", Double.class));*/
JSONObject object = JSONObject.parseObject(response).getJSONObject("result").getJSONObject("location");
acc.setAccLng(object.getObject("lng", Double.class));
acc.setAccLat(object.getObject("lat", Double.class));
scAccService.updateScAcc(acc);
}
}
}
brother
Happy songfanping kept laughing when he walked out of the photo studio , His happiness infected Li Lan , As they walked on , These two people have been laughing , Then Li baldheaded and Song Gang also giggled , Although the two children don't know why they laugh .
Remarried Li Lan was jubilant , Since her former husband drowned in the toilet , She survived seven years rather than death , Her hair has been in a doghouse for seven years , Now she has recovered her girl's pigtails , Also tied two red ropes at the end of the braid . Her face * It's like eating ginseng, and it suddenly turns ruddy , Her migraine headache suddenly disappeared , After hissing for seven years, her mouth began to hum a song . Her remarried husband is also red , As he walked in and out of the room, his feet thumped like drums , When he peed against the wall outside, it sounded like a storm .
This two married couple were like glue in their honeymoon , Once they seize the leisure, they will hide in the inner room , And the door is closed . Li baldhead and Song Gang can only fantasize in the outside room , The two children heard their mouths crackling when they were inside , Firmly believe that they hide inside and eat that bag of white rabbit milk candy . They not only eat during the day , In the evening, I can't stop eating . Before dark, they would force Li baldhead and Song Gang to go to bed , They shut themselves in the back room , Two mouths keep ringing . At this time, the neighbor's children were still running and shouting outside , Li baldhead and Song Gang can only go to bed , Songfanping and Li Lan also went to bed , But their mouths kept ringing in the room inside . Li baldheaded and Song Gang fell asleep with tears and drooling , When I woke up the next morning, my tears dried up , Saliva is still flowing .
————————————————
Copyright notice : This paper is about CSDN Blogger 「 When can the dead wood fall in spring 」 The original article of , follow CC 4.0 BY-SA Copyright agreement , For reprint, please attach the original source link and this statement .
Link to the original text :https://blog.csdn.net/weixin_45953673/article/details/125686838
边栏推荐
- How can a novice quickly complete the establishment of a website? Come to the free "fitting room" experience
- Tik tok "founder" Yang Luyu, farewell byte?
- How to build knowledge management system in enterprises and institutions
- Several ways to bind controls --butterknife/viewbinding/databinding
- Arduino Pro Mini atmega328p connect and light the first LED (at the same time, record the problem of burning failure stk500_recv)
- On Governance and innovation | the openanolis sub forum of the 2022 open atom global open source summit was successfully held
- 【vulnhub】presidential1
- Anhui Jingzhun: Beidou satellite synchronous clock | Beidou synchronous clock | NTP network clock server
- Tencent two sides: @bean and @component are used in the same class, what will happen?
- [try to hack] UDF raises rights
猜你喜欢

Brief discussion on open source OS distribution

【一知半解】零值拷贝

DIY system home page, your personalized needs PRO system to meet!

聚变云原生,赋能新里程 | 2022 开放原子全球开源峰会云原生分论坛圆满召开

Fusion cloud native, enabling new mileage | 2022 open atom global open source summit cloud native sub forum successfully held

安徽京准:北斗卫星同步时钟|北斗同步时钟|NTP网络时钟服务器

奥浦迈生物通过注册:半年营收1.47亿 国寿成达与达晨是股东

Uninstall Navicat: genuine MySQL official client, really fragrant!

Kuzaobao: summary of Web3 encryption industry news on July 13

Industry, University, research and application jointly build an open source talent ecosystem | the 2022 open atom global open source summit education sub forum was successfully held
随机推荐
How to build knowledge management system in enterprises and institutions
缺少指令集umi2 怎么办?ptk方式安装无法进行
If you don't roll the golden nine and silver ten, it's too late
【vulnhub】presidential1
用C语言开发NES游戏(CC65)07、控制器(和精灵碰撞)
Developing NES games with C language (cc65) 08. Background collision
PHP timestamp subtraction converts to days, hours, minutes and seconds
PHP date calculation operation processing, the current date plus one day and the specified date minus one day
论治理与创新 | 2022 开放原子全球开源峰会 OpenAnolis 分论坛圆满召开
Full analysis of seven classical regression analysis methods
社区点赞业务缓存设计优化探索
用C语言开发NES游戏(CC65)03、VRAM缓冲区
IRBuilder
Laravel $object->updated_ At returns the carbon object. How to return the normal time format
Is it difficult for cloud native machine learning to land? Lingqueyun helps enterprises quickly apply mlops
Google Earth engine (GEE) -- problems in the use of coordinate projection and reduceresolution functions in image downscaling
arduino pro mini ATMEGA328P 连线和点亮第一盏LED(同时记录烧录失败的问题stk500_recv)
让arduino支持nuvotom新唐
Play with poetry - appreciate the beauty of ancient poetry
用C语言开发NES游戏(CC65)09、滚动