Parsing JSON data in Java

后端 未结 2 923
失恋的感觉
失恋的感觉 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.

    0 讨论(0)
  • 2021-01-24 23:12

    use something like JSONGen to better understand your data structures, maybe even map your data to the generated objects using google-gson library

    0 讨论(0)
提交回复
热议问题