JSONObject类所需要的jar文件
实验代码
JSONObject jsonObj
=new JSONObject();
jsonObj
.put("command", Client
.COMMAND_LOGIN
);
jsonObj
.put("user_id", userId
);
jsonObj
.put("user_pwd", password
);
byte[] b
=jsonObj
.toString().getBytes();
DatagramPacket packet
=new DatagramPacket(buffer
, buffer
.length
, address
, Client
.SERVER_PORT
);
Client
.socket
.send(packet
);
packet
=new DatagramPacket(buffer
, buffer
.length
, address
, Client
.SERVER_PORT
);
Client
.socket
.receive(packet
);
所需要的jar文件名 文件在下载的地方 JSONObject.jarJSONObject()不能传入String类型的值, 引用的包不对,需要用org.json.jar才可以传入string类型的参数,下载链接如下: https://search.maven.org/search?q=g:org.json%20AND%20a:json&core=gav
转载请注明原文地址: https://mac.8miu.com/read-508829.html