我尝试使用发送JSON从安卓到的NodeJS服务器
HttpURLConnection con = (HttpURLConnection) (new URL(IP + "/getrestaurant")).openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Accept", "application/json");
con.setDoInput(true);
con.setDoOutput(true);
con.connect();
con.getOutputStream().write("{'restaurant_id':'569a16e28dcdc5c8add2a8e0'}".getBytes("UTF-8"));
con.getOutputStream().flush();
con.getOutputStream().close();
从Android设备发送请求到的NodeJS服务器当我打印从节点JS接收到的请求,我得到:
{
"{'restaurant_id':'569a16e28dcdc5c8add2a8e0'}": ""
}
而不是{'restaurant_id':'569a16e28dcdc5c8add2a8e0'}
我该如何得到它的工作?谢谢!
'{“restaurant_id”:“569a16e28dcdc5c8add2a8e0”}'是不是有效的JSON ... – Selvin