[英]When trying to retrieve JSONObject out of JSONArray is returning null?
[英]Android JSONObject becomes null when trying to send
當我嘗試將JSONObject
推入數據流時,並且已經正確構建了JSONObject
,但是隨后我嘗試將其發布到流中,因此它為null。
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
嘗試pubNub.publish().message(position.toString());
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.