【发布时间】:2021-04-06 11:11:33
【问题描述】:
我正在尝试使用以下代码转换消息:
String message = (String) JSONObject.stringToValue(record.value().toString());
使用 springboot 版本为 2.4.4 时出现以下错误,但在以下版本中运行良好。
Error = The method stringToValue(String) is undefined for the type JSONObject
下面是用于上述转换的maven依赖:
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180813</version>
</dependency>
有人可以就此提出建议吗?
【问题讨论】:
-
在发生错误的情况下,您确定
JSONObject来自org.json吗? -
是的@GauthamM .. 这是导入 - 导入 org.json.JSONObject;
标签: java json spring-boot