如何通过Socket在Java和Python之间传递Json对象?我尝试了一个简单的套接字,但没有成功,在python代码中,我仅收到JSON对象的一部分。下面我展示我的尝试:
JAVA代码:
socket = new Socket(dstAddress, dstPort);
try (OutputStreamWriter out = new OutputStreamWriter(socket.getOutputStream(), StandardCharsets.UTF_8)) {
out.write(jsonObject.toString());
}
Python代码:
while (1):
print("\n\nAttending for client.....\n\n")
conn, addr = s.accept()
print "Connected by: " , addr
data = conn.recv(80000)
print(data)
感谢您的提前帮助!