discomarathon / google-gson

Automatically exported from code.google.com/p/google-gson
0 stars 0 forks source link

No User Manual for JsonStreamParser #181

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I am using Gson 1.4 Beta.

The Roadmap (1.4 Beta) states:

"JsonStreamParser: A streaming parser API class to deserialize multiple
JSON objects on a stream (such as a pipelined HTTP response)."

However, I cannot find any info in the user manual or API about it. The
search in the issues database does pick up anything with
"JsonStreamParser". Search in the User Manual or Gson site yields nothing
other than the Roadmap.

This is fundamental to process large object maps from/to the Json
InputStream/OutputStream with another InputStream/OutputStream.

For example, with JDO, we should be able to:

   Type listType = new TypeToken<List<MyJDO>>() {}.getType();
   InputStream ins = fileItemStream.openSream();
   JasonInputStream jins = gson.fromJsonStream(ins, listType);

   while ((MyJDO jdo = jins.readNextJson()) != null)
   {
       pm.makePersistent(jdo);
   }

If I use 

   List<MyJDO> list = gson.fromJson(ins, listType); 

and get the entire List, that is too large. It exceeds memory limit and it
takes a long time to store it away with pm.makePersistentAll() (if it does
not crash the app). By any rate, the makePersistentAll() uses iterator
anyway, so it seems to have the same efficiency.

I believe that this is a deficient item.

Yoichi

Original issue reported on code.google.com by takayama...@gmail.com on 22 Dec 2009 at 4:02

GoogleCodeExporter commented 9 years ago
FYI: if this is still to be a problem, the new JsonReader class makes it 
possible to consume a JSON stream in parts. Better integration between Gson and 
JsonReader in the public API is forthcoming.

Original comment by limpbizkit on 27 Aug 2010 at 7:40

GoogleCodeExporter commented 9 years ago
http://sites.google.com/site/gson/streaming

Original comment by limpbizkit on 5 Oct 2010 at 6:43