I have a Json object which has the following data
{\”data\”:{\”pdp0:\”:{\”recv\”:{\”packets\”:\”15104\”,\”bytes\”:\”9059817\”},\”sent\”:{\”packets\”:\”9480\”,\”bytes\”:\”1687801\”}},\”gre0:\”:{\”recv\”:{\”packets\”:\”0\”,\”bytes\”:\”0\”},\”sent\”:{\”packets\”:\”0\”,\”bytes\”:\”0\”}},\”tunl0:\”:{\”recv\”:{\”packets\”:\”0\”,\”bytes\”:\”0\”},\”sent\”:{\”packets\”:\”0\”,\”bytes\”:\”0\”}},\”usb0:\”:{\”recv\”:{\”packets\”:\”0\”,\”bytes\”:\”0\”},\”sent\”:{\”packets\”:\”0\”,\”bytes\”:\”0\”}},\”lo:\”:{\”recv\”:{\”packets\”:\”48300\”,\”bytes\”:\”2616703\”},\”sent\”:{\”packets\”:\”48300\”,\”bytes\”:\”2616703\”}}},\”ver\”:\”1.4\”,\”type\”:\”netdev\”,\”date\”:\”2011-4-13 14:10:21\”,\”user\”:\”351863047772880\”,\”time_stamp\”:1305313821541}
If I want to access the data in data->pdp0->recv->packets (here the value is 15104) which function should I use?
thanks
sarath
You can use the plain old org.json package to get the nested objects:
API details here: http://www.json.org/javadoc/org/json/JSONObject.html