我正在尝试做一个可以JSONObject
通过HttpConnection
POST 请求发送的 blackbery 应用程序。JSON对象是
{
"Contrasena" : "hy1tSPQc3K4IlSZLvd7U7g==",
"Plataforma" : "A",
"Usuario" : "user2323"
}
有谁知道怎么做?
我正在尝试做一个可以JSONObject
通过HttpConnection
POST 请求发送的 blackbery 应用程序。JSON对象是
{
"Contrasena" : "hy1tSPQc3K4IlSZLvd7U7g==",
"Plataforma" : "A",
"Usuario" : "user2323"
}
有谁知道怎么做?
您可以为此使用URLEncodedPostData类。使用喜欢
httpConn.setRequestMethod(HttpConnection.POST);
httpConn.setRequestProperty("Content-Type", "application/json");
URLEncodedPostData encPostData = new URLEncodedPostData("UTF-8", false);
encPostData.setData(JsonString);//set your jsonstring
byte[] postData = encPostData.toString().getBytes("UTF-8");
httpConn.setRequestProperty("Content-Length", String.valueOf(postData.length));
httpConn.openOutputStream().write(encPostData.getBytes());
int Response = httpConn.getResponseCode();