当我试图将JSONObject
推过数据流时,我已经正确构建了JSONObject
,但随后我尝试将其发布到流,它是空的。
JSONObject position = new JSONObject();
try {
position.put("lat", location.getLatitude());
position.put("lng", location.getLongitude());
} catch (JSONException e) {
System.out.println("json not work");
e.printStackTrace();
}
System.out.println(position) //result: {"lat":37,"lng":-122}
pubNub.publish().message(position)//never sent, if other type it works
try pubNub.publish().message(position.toString());