当前位置:网站首页>Parse JSON interface and insert it into the database in batch
Parse JSON interface and insert it into the database in batch
2022-06-26 04:04:00 【Lie down and count the stars】
Interface for NBA Interface json Interface
Use hutool Tool classes are parsed at the back end ( Prevent cross domain )
@GetMapping("/pachou")
public String teamMessage() {
s = HttpUtil.get("https://china.nba.cn/stats2/season/conferencestanding.json?");
return s;
}
Get the data transferred from the front end fastJSON Parse and batch insert
@PostMapping("/addBatch")
public Result addBatch(@RequestBody String str) {
JSONArray jsonArray = JSONArray.parseArray(str);
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject json = JSONObject.parseObject(jsonArray.get(i).toString());
String profile = json.getString("profile");
JSONObject jsons = JSONObject.parseObject(profile);
String city = jsons.getString("city");
String abbr = jsons.getString("abbr");
String cityEn = jsons.getString("cityEn");
String displayConference = jsons.getString("displayConference");
String displayAbbr = jsons.getString("displayAbbr");
String nameEn = jsons.getString("nameEn");
String division = jsons.getString("division");
Team team = new Team();
team.setAbbr( abbr);
team.setCityEn(cityEn);
team.setCreateTime(DateUtil.format(new Date(), "yyyy-MM-dd hh:mm:ss"));
team.setDisplayConference(displayConference);
team.setDisplayAbbr(displayAbbr);
team.setNameEn(nameEn);
team.setDivision(division);
teamService.save(team);
}
return Result.success(" success ");
}
front end vue Send a request
// send data
send: function () {
request.get("/team/pachou").then(res => {
console.log(res)
this.standingGroups = res.payload.standingGroups[1].teams
console.log(this.standingGroups)
// JSON.stringify(this.standingGroups)
/* this.standingGroups.forEach(e=>{ JSON.stringify(this.standingGroups) console.log(JSON.stringify(this.standingGroups)); })*/
request.post("/team/addBatch",this.standingGroups).then(res => {
console.log(res)
})
})
},

Be accomplished 1
边栏推荐
- Camera-CreateCaptureSession
- Question brushing record day01
- 商城风格也可以很多变,DIY 了解一下
- 钉钉开放平台-小程序开发实战(钉钉小程序客户端)
- WPF value conversion
- asp.net网页选择身份进行登录的简单代码,asp连接数据库,使用asp:Panel、asp:DropDownList控件
- 軟件調試測試的十大重要基本准則
- Prism framework project application - Navigation
- MapReduce执行原理记录
- 2020 summary: industrial software development under Internet thinking
猜你喜欢

Open source! Vitae model brushes the world's first again: the new coco human posture estimation model achieves the highest accuracy of 81.1ap

Yolov5 improvements: replace the backbone

开源!ViTAE模型再刷世界第一:COCO人体姿态估计新模型取得最高精度81.1AP

After a test of 25K bytes, I really saw the basic ceiling

Custom parameter QR code picture combined with background picture to generate new picture node environment

用eclipse连mysql数据库出错然后出现图中的话是咋回事呀

外包干了四年,人直接废了。。。

高性能算力中心 — RoCE — Overview

【Flink】Flink源码分析——批处理模式JobGraph的创建

软件调试测试的十大重要基本准则
随机推荐
Unity mobile game performance optimization spectrum CPU time-consuming optimization divided by engine modules
What preparations should be made to develop an app from scratch
神经网络学习小记录71——Tensorflow2 使用Google Colab进行深度学习
xml 解析bean工具类
1.基础关
The stc-isp burning program for 51 single chip microcomputer always shows that "the target single chip microcomputer is being detected..." the cold start board does not respond
在出海获客这件事上,数字广告投放之外,广告主还能怎么玩儿?
Contains an object field at offset position
链路监控 pinpoint
Prism framework project application - Navigation
高性能算力中心 — RoCE — Overview
Sorting out the knowledge points of the renderview renderobject parentdata of the shuttle
Open Camera异常分析(一)
chrome页面录制,重放功能
Spark - understand parquet
ASP. Net core introduction
asp. Net web page, ASP connects to the database, and uses asp:panel and asp:dropdownlist controls
Binary search method
線程同步之讀寫鎖
The style of the mall can also change a lot. DIY can learn about it