Send JSON data from in socket.io from android
You can use a Gson object that permit to transform your object into a JSON String, and apply a conversion to a JSONObject like this :
Entity en = new Entity();Gson gson = new Gson();try { JSONObject obj = new JSONObject(gson.toJson(en)); socket.emit("entity", obj);} catch (JSONException e) { e.printStackTrace();}
This is how I do. To use Gson, you should add a Gradle dependency :
compile 'com.google.code.gson:gson:2.+'