尝试发送时,Android JSONObject变为null

时间:2016-09-03 01:05:50

标签: java android json stream

当我尝试在数据流上推送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

1 个答案:

答案 0 :(得分:0)

尝试pubNub.publish().message(position.toString());