Reading a json file using Gson in play framework
I'm using Play framework, I want to read a json file, I have a json file with contents similar to
{"columns_map":["SenderName","Message","Device","Acknowledge","Time"],"rows_map":{"219":["mahesh","come soon","Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1","Data Inserted Successfully",""]}}
SenderName,Message, Device,Acknowledge,Time will be columns for JQuery datatable, rows_map will be the records, I can't feed the file directly to JQuery since i have to perform conditions and display a certain records.
There will be 5 lakh records inside the file. Is it best to gson or other parser(which one please?) or create own encoder/decoder functionality How to parse the file 开发者_开发百科so that i can feed the datatable as i wanted.
Using gson should work. Just import com.google.gson.*
Those files are already included with Play!
GSON parser is fast and efficient. You can use Play jobs to process this large json file (of 5 lakh recs) and after processing cache this file on the file-system.
From the front-end, use ajax to retrieve - only the required number of records that would be displayed on the table in the browser. The play controller handling this ajax call should retrieve the cached json file and render the json. This also should keep track of the record pointer - kind of custom pagination
精彩评论