Java 无法通过方法调用转换将JSONObject转换为字符串
(新手警报) 我正在使用和 在解决了Java 无法通过方法调用转换将JSONObject转换为字符串,java,json,websocket,type-conversion,invocation,Java,Json,Websocket,Type Conversion,Invocation,(新手警报) 我正在使用和 在解决了putting与JSONObject的问题后,我现在正试图解决这个问题,但我得到了 error: method sendToAll in class WebSocketServerBase cannot be applied to given types; ws.sendToAll(obj); ^ required: String found: JSONObject reaso
put
ting与JSONObject
的问题后,我现在正试图解决这个问题,但我得到了
error: method sendToAll in class WebSocketServerBase cannot be applied
to given types;
ws.sendToAll(obj);
^
required: String
found: JSONObject
reason: actual argument JSONObject cannot be converted to String by method
invocation conversion
1 error
我怎样才能
sendToAll
obj
?obj
是一个JSONObject
,该方法需要一个字符串。我确信有某种方法可以将你的obj
转换成一个String
来识别它,但我不知道它是什么。请做更多的研究并找到答案,然后我会投票支持快速响应。非常令人惊讶,因为我对json一无所知!!我知道如何读取编译器错误