-2

How to convert json in android There is a message of the form

{"type": "message", "data": {"time": 1385077892240, "text": "Hello", "author": false, "color": false}}

how to convert to Android

Loovery
  • 3
  • 2
  • Not sure what your question is really asking here. – kabuto178 Nov 22 '13 at 00:39
  • What have you tried? You can hardly expect us to do your work without showing you've actually put some effect into attempting to solve the problem yourself. – MH. Nov 22 '13 at 00:55

2 Answers2

0

Maybe your question is how to use json format in java, there will be many third party library u can found by google. I don't use java, but i heard the GSON library which is provided by google.

freedoo
  • 691
  • 1
  • 5
  • 12
0

You can do this:

import org.json.JSONException;
import org.json.JSONObject;

String strJSON;
JSONObject json;

strJSON = "{\"type\": \"message\", \"data\": {\"time\": 1385077892240, \"text\": \"Hello\", \"author\": false, \"color\": false}}";

try {
json = new JSONObject(strJSON);
Log.d("JSON-Obj", json.getString("type"));
} catch (JSONException e) {
    // TODO Auto-generated catch block
e.printStackTrace();
}
Gustavo
  • 605
  • 6
  • 11