Skip to content
Advertisement

org.json.simple.JSONArray cannot be cast to class org.json.simple.JSONObject

I keep getting this error and already searched a lot and cant seem to solve it. Basically i am trying to read a json file and store some of its data in a database. Hope you guys know how to solve this! This json file is from a statistics site and i want to store the most important data in a database table i created with SQLite. Thanks for all the help, cheers 😀

This is the error i keep getting:

JavaScript

This is my JSON file:

JavaScript

And this is my code:

JavaScript

Advertisement

Answer

Read file into String and parse as JSONArray:

JavaScript

Convert the String to a JSONArray:

JavaScript

Read values one by one:

JavaScript

or iterate through the JSONArray

JavaScript

Hope this helps !!

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement