I have a file that contains JSON objects. I am trying to access the file using its URL in my java program to access its contents as follows.
URL url = new URL(Url);
URLConnection request = url.openConnection();
request.connect();
JsonReader jr = new JsonReader(new InputStreamReader((InputStream) request.getContent()));
jr.setLenient(true);
JsonParser jp = new JsonParser();
JsonElement root = jp.parse(jr);
I have to use the jr.setLenient(true);
since the data is not a JSON object, but multiple JSON objects. But this approach does not help me to get all the JSON objects in the file. I am trying to get all the JSON objects, loop through each one of them and then save the data into my database.
I have the sample of the type of data I receive at the following URL: Sample File
Is there any way in which I can get all the objects in the file to perform the required operations.
Also, I can manually save the data into a JSON array in a new file manually if nothing works, but there is no comma separation between each JSON object which is making it very difficult for me to parse the data.
But each JSON object is a new line. So is there any way to parse it based on that.