【发布时间】:2016-08-03 09:07:16
【问题描述】:
JSON:
{
"deviceId": "AAAAAAA1",
"cardInfo": {
"pan": "123456789012345",
"psn": "00",
"cvv": "123",
"panExpiryDate": "2017-12-12"
},
"productType": "CREDIT",
"requestor": 1234,
"aid": "A000000001234567",
"aidVersion": 1,
"panSource": null,
"deviceLanguage": "en"
}
安卓代码:
protected String doInBackground(Void... params) {
Bundle bundle=getIntent().getExtras();
final String newdata=bundle.getString("newdata");
try {
js=new JSONObject(newdata);
di=js.getString("deviceId");
} catch (JSONException e) {
e.printStackTrace();
}
postDataParams = new HashMap<String, String>();
postDataParams.put("deviceId",deviceID);
postDataParams.put("cardInfo.pan",card);
postDataParams.put("cardInfo.psn",Psn);
postDataParams.put("cardInfo.cvv",cvv);
postDataParams.put("cardInfo.panExpiryDate",panExpiryDate);
postDataParams.put("productType",productType);
postDataParams.put("requestor",requestor);
postDataParams.put("aid",aid);
postDataParams.put("aidVersion",aidVersion);
postDataParams.put("panSource",panSource);
postDataParams.put("deviceLanguage",deviceLanguage);
response = service.postServerData(path,postDataParams);
try {
json = new JSONObject(response);
System.out.println("success " + json.get("success"));
success = json.getInt("success");
} catch (JSONException e) {
e.printStackTrace();
}
return response;
}
在编写此代码时,未收到来自 url 的任何响应。你能帮我在哪里做错吗?
【问题讨论】:
-
“给我发送完整的代码”在 Stackoverflow 上不起作用,这里是提问和回答的地方,而不是让其他人免费为您编码。请描述您的问题,添加您正在努力解决的相关代码,希望有人能够提供帮助。
-
您希望生成的
HashMap的键是什么格式?您发布的代码有哪些不起作用或不完整的地方? -
您需要获取字符串对象类型的hasmap。在该hashmap中放入一个带有key cardInfo的json对象。
-
已添加代码....请帮助