I need to parse a large JSON payload which has unknown data records. I need to do some processing with each record. I cannot hold the whiole payload in memory so I need to parse it object by object between { and } and send it gson jsonReader api for further processing. I am not able to sen the whole payload to jsonReader as the Whole payload is not wellformed JSON thats why individual JSON parsing is needed. Please help.
sample data 1st payload : [{"key":"value","key2,":"value2".....},{"key":"valu e6","key2,":"value20".....},.......},
JsonReader parses the first payload till the end of file but throws endoffile exception at the last record(malformed json) in above example it is looking for ] instead of ','
java.io.EOFException: End of input at line 1 column 44259740
com.google.gson.stream.MalformedJsonException: Unexpected value at line 1 column 2747 path $
First Payload calls the second Payload - response of which has partial json structure as :
{"key":"value","key2,":"value2".....},{"key":"valu e6","key2,":"value20".....},.......},
last payload json structure:
{"key":"value","key2,":"value2".....},{"key":"valu e6","key2,":"value20".....},.......}]
all these payload are different format therefore need to parse individual objects and then send to JSONReader object.
How to I achieve this? Please help