user3243651
user3243651

Reputation: 241

Send JSON to server

I need to send JSON object as String to my server and I did this:

json.put("TYPE", "1");
            json.put("CODE", "0");
            json.put("NODEID", id);
            json.put("TSTAMP", mtemporal);
            json.put("XPOS", lastx);
            json.put("YPOS", lasty);
            json.put("HDOP", "");
         telo=json.toString();

where telo is a String. and when i send telo in my server I obtain this:

Object {command: "MESSAGE", headers: Object, body: "[Ljava.lang.String;@429106c0", id: undefined, receipt: undefined…}

The problem is that in body should be appears the json object and appear something like address memory

How can i solve it?

Thansk

[EDIT]

I update the post.. I send Json object, really a String, using Gozirra API, wich allows connect and send data to activemq server using STOMP protocol

More code:

public void send(float lastx,float lasty,String id,String mtemporal) {


        try {
            json.put("TYPE", "1");
            json.put("CODE", "0");
            json.put("NODEID", id);
            json.put("TSTAMP", mtemporal);
            json.put("XPOS", lastx);
            json.put("YPOS", lasty);
            json.put("HDOP", "");
         telo=json.toString();
        } 
        catch (JSONException e) {
            e.printStackTrace();
        }

        new Send().execute(telo);

    }


public class Send extends AsyncTask<String, Void, Void> {

    @Override
    protected Void doInBackground(String... params) {
        Log.i("telo", "estoy para enviar");
        c.begin();
        c.send("/topic/LOCATIONJSON", String.valueOf(params));
        c.commit();
        return null;
    }

}

Upvotes: 0

Views: 178

Answers (1)

Jorge Alfaro
Jorge Alfaro

Reputation: 924

String.valueOf(params) should be String.valueOf(params[0]) it gives you an address memory because you a representing a String array, not the String itself

Upvotes: 2

Related Questions