Parsing JSON data in Java

后端 未结 2 961
失恋的感觉
失恋的感觉 2021-01-24 22:18

I want to parse the some data from this page: http://www.bbc.co.uk/radio1/programmes/schedules/england/2013/03/1.json

The data I want to parse is the titles however I am

2条回答
  •  心在旅途
    2021-01-24 23:06

    If you read the javadoc of JSONObject#get(String) which is actually HashMap.get(String), it states

    Returns: the value to which the specified key is mapped, or null if this map contains no mapping for the key

    Your JSON does not contain a mapping for the key time.

    Edit:

    If you meant title instead of time, take this extract of the JSON

    {"schedule":{"service":{"type":"radio","key":"radio1","title":"BBC Radio 1",...
    

    You need to first get schedule as a JSONObject, then service as a JSONObject, and then title as a normal String value. Apply this differently depending on the type of JSON value.

提交回复
热议问题