From 3f88a20557094af9d4f58d019f586560f04a45ce Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Mon, 26 Aug 2024 10:00:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=8B=BC=E9=9F=B3api?= =?UTF-8?q?=E7=9A=84=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/yutou/tools/ToolsApplication.java | 2 +- src/main/java/com/yutou/tools/utils/Tools.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/yutou/tools/ToolsApplication.java b/src/main/java/com/yutou/tools/ToolsApplication.java index aed4bd8..713d295 100644 --- a/src/main/java/com/yutou/tools/ToolsApplication.java +++ b/src/main/java/com/yutou/tools/ToolsApplication.java @@ -6,7 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class ToolsApplication { - public static final String version="1.5.0"; + public static final String version="1.5.1"; public static void main(String[] args) { System.out.println("当前版本号:" + version); diff --git a/src/main/java/com/yutou/tools/utils/Tools.java b/src/main/java/com/yutou/tools/utils/Tools.java index 6fda890..82bec8d 100644 --- a/src/main/java/com/yutou/tools/utils/Tools.java +++ b/src/main/java/com/yutou/tools/utils/Tools.java @@ -462,7 +462,7 @@ public class Tools { String pinyin = HttpTools.get("https://apis.tianapi.com/pinyin/index?key=" + ConfigTools.load(ConfigTools.CONFIG, "tianapi.key", String.class) + "&text=" + URLEncoder.encode(text, StandardCharsets.UTF_8)); JSONObject json = JSONObject.parseObject(pinyin); if (json.getInteger("code") == 200) { - return json.getJSONArray("newslist").getJSONObject(0).getString("pinyin").trim().replace(" ", ""); + return json.getJSONObject("result").getString("pinyin").trim().replace(" ", ""); } return ""; } @@ -488,4 +488,8 @@ public class Tools { return null; } } + + public static void main(String[] args) { + System.out.println(getPinYin("你好")); + } }