修复FastJSON大版本更新后API变动

This commit is contained in:
2022-04-28 09:50:33 +08:00
parent f1ed4be143
commit 7943606dc0
22 changed files with 103 additions and 88 deletions

View File

@@ -1,7 +1,8 @@
package com.yutou.qqbot.utlis;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.qqbot.QQBotManager;
import com.yutou.qqbot.models.Model;
@@ -25,7 +26,7 @@ public class BangumiTools {
*/
public static JSONObject getBangumi(int day) {
String str = HttpTools.get(toDayBangumi);
JSONArray main = JSONArray.parseArray(str);
JSONArray main = JSON.parseArray(str);
if (day == -1) {
JSONObject json = new JSONObject();
json.put("bangumi", main);
@@ -60,7 +61,7 @@ public class BangumiTools {
*/
public static JSONObject getBangumiInfo(int id) {
String str = HttpTools.get(String.format(BangumiInfo, id + ""));
return JSONObject.parseObject(str);
return JSON.parseObject(str);
}
public static JSONArray getPeople(int id) {
@@ -117,7 +118,7 @@ public class BangumiTools {
*/
public static JSONObject search(String key) {
String str = HttpTools.get(String.format(SearchBangumi, URLEncoder.encode(key, StandardCharsets.UTF_8)));
return JSONObject.parseObject(str);
return JSON.parseObject(str);
}
/**

View File

@@ -1,6 +1,7 @@
package com.yutou.qqbot.utlis;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import java.io.*;
@@ -44,7 +45,7 @@ public class ConfigTools {
String src = readFile(file);
if (src != null) {
try {
JSONObject json = JSONObject.parseObject(src);
JSONObject json = JSON.parseObject(src);
return json.getObject(key, t);
} catch (Exception e) {
}
@@ -80,7 +81,7 @@ public class ConfigTools {
if (src == null) {
src = "{}";
}
JSONObject json = JSONObject.parseObject(src);
JSONObject json = JSON.parseObject(src);
json.put(key, data);
saveFile(file, json.toJSONString());
return false;

View File

@@ -1,6 +1,6 @@
package com.yutou.qqbot.utlis;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.qqbot.interfaces.DownloadInterface;
import org.jetbrains.annotations.NotNull;

View File

@@ -1,6 +1,7 @@
package com.yutou.qqbot.utlis;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.qqbot.QQBotManager;
import com.yutou.qqbot.interfaces.ObjectInterface;
import redis.clients.jedis.Jedis;
@@ -292,7 +293,7 @@ public class RedisTools {
public static void bot(String value) {
switch (value) {
case "getip":
JSONObject json = JSONObject.parseObject(HttpTools.get("https://api.asilu.com/ip/"));
JSONObject json = JSON.parseObject(HttpTools.get("https://api.asilu.com/ip/"));
String ip = json.getString("ip");
QQBotManager.getInstance().sendMessage("服务器IP:\n" + ip);
break;

View File

@@ -1,7 +1,7 @@
package com.yutou.qqbot.utlis;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import org.openqa.selenium.Cookie;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
@@ -49,8 +49,8 @@ public class WebClient {
json.getString("domain"),
json.getString("path"),
containsDate ? new Date(t) : new Date(),
json.containsKey("secure")?json.getBoolean("secure"):false,
json.containsKey("httpOnly")?json.getBoolean("httpOnly"):false
json.getBooleanValue("secure"),
json.getBooleanValue("httpOnly")
);
list.add(cookie);

View File

@@ -1,6 +1,7 @@
package com.yutou.qqbot.utlis;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import org.apache.commons.codec.digest.DigestUtils;
import java.nio.charset.StandardCharsets;
@@ -24,7 +25,7 @@ public class XiaoMiRouter {
json.put("password", oldPwd);
json.put("logtype", 2);
json.put("nonce", nonce);
json = JSONObject.parseObject(HttpTools.http_post("http://192.168.31.1/cgi-bin/luci/api/xqsystem/login", HttpTools.toUrlParams(json).getBytes(StandardCharsets.UTF_8), 1, null));
json = JSON.parseObject(HttpTools.http_post("http://192.168.31.1/cgi-bin/luci/api/xqsystem/login", HttpTools.toUrlParams(json).getBytes(StandardCharsets.UTF_8), 1, null));
if (json.getInteger("code") == 0) {
token = json.getString("token");
return token;
@@ -42,7 +43,7 @@ public class XiaoMiRouter {
public static void main(String[] args) {
String url = XiaoMiRouter.getDeviceListUrl();
JSONObject json = JSONObject.parseObject(HttpTools.get(url));
JSONObject json = JSON.parseObject(HttpTools.get(url));
System.out.println("json = " + json);
}
}