I have a large JSON file of 121MB. I want to read its structure and the data. I am unable to read it with notepad++ and json editor plugin of chrome. I have tried reading it with java. simple json reading is also giving exception:
Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded
If i use jackson streaming API. How do I read the structure and data completely? I do not know its json structure keys and values. I used code like this:
import java.io.File;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
public class JacksonStreamExample {
public static void main(String[] args) {
try {
JsonFactory jfactory = new JsonFactory();
/*** read from file ***/
JsonParser jParser = jfactory.createParser(new File(
"E:\\NUST\\Semester 3\\region_descriptions.json"));
while (jParser.nextToken() != JsonToken.END_OBJECT) {
System.out.println(jParser.getCurrentName());
jParser.nextToken();
System.out.println(jParser.getText());
}
jParser.close();
} catch (JsonGenerationException e) {
e.printStackTrace();
}catch (IOException e) {
e.printStackTrace();
}
}
}
Is there any way to read it with any text or JSON viewer? or with a java code? If java code, how to read the JSON structure?