discomarathon / google-gson

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

Read and write log files where each entry is in JSON format #32

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Perhaps Gson would be useful for reading and writing logs where each entry
is in JSON format?

I haven't looked closely, but it appears that Gson won't emit a newline
when serializing to a file.  If this is something that Gson could
guarantee, then we could use newlines as record separators and make each
log entry a JSON object, and also use GSon to iterate over a log file and
deserialize each line into an object.

Original issue reported on code.google.com by bslesinsky on 15 Aug 2008 at 3:39

GoogleCodeExporter commented 9 years ago
Yes, by default, Gson uses compact formatting, eliminating all white-space so it
should never write a new line. 

Original comment by inder123 on 15 Aug 2008 at 6:10

GoogleCodeExporter commented 9 years ago
Closing the bug since this was a question, not an issue. The best place to post 
such
questions is the Google group for Gson, 
http://groups.google.com/group/google-gson

Original comment by inder123 on 15 Aug 2008 at 6:12

GoogleCodeExporter commented 9 years ago
Okay, but I think there is an issue: it's not documented that toJson() will 
return a
String in compact formatting.  Also, I don't think there's a formal definition 
of
what compact formatting means.

Original comment by bslesinsky on 15 Aug 2008 at 4:01

GoogleCodeExporter commented 9 years ago
That is a good point, and we need to explain all the default settings used by 
Gson. I
have added it in r157 to the javadoc for the default constructor of Gson(). 

Original comment by inder123 on 15 Aug 2008 at 7:55