I have a android project in which I tried to read and store information from json file. But it's not straightforward because I don't know how to extract string from this type of json. From the json file, it seems like it's a json inside a json? Following is the json formatted data
{
"Meta Data": {
"1. Information": "some information",
"2. Symbol": "something",
"3. Last Refreshed": "time",
"4. Interval": "1min",
"5. Output Size": "Compact",
"6. Time Zone": "US/Eastern"
}
}
I have tried the following but it does not seem to work
try {
JSONObject object = new JSONObject(message);
JSONArray Jarray = object.getJSONArray("Meta Data");
for (int i = 0; i < Jarray.length(); i++)
{
JSONObject Jasonobject = Jarray.getJSONObject(i);
JSONArray a = Jasonobject.getJSONArray("1. Information");
Log.i(TAG, "onReceive: ");
}
}catch{
e.printStackTrace();
}
When I debugged my application I got following message in console
org.json.JSONException: No value for Meta Data
What I am trying to do is extract "something","some information" into variables. Can anyone tell me what's wrong with my code? Is there a better way and if so could you please share the code snippet? Thanks