[android-developers] Re: Which JSON Parser is better

2011-02-22 Thread Manish Garg
I used gson and it was working fine but in some cases i got
deserialization error or wrong format in case of stroing dates in long
and then parsing them. Jackson doesn't give this error and solving my
problem. Now I am bit confused which one i should used because size of
jackson is more than gson and i do not need all functionality of the
jackson. i need only fromJson function of gson or
mapper.readValue(response, classType) of jackson.

I am also not very sure about the performance of jacson and gson.
Jackson looks bit slow.

On Dec 29 2010, 1:15 am, Bob Kerns r...@acm.org wrote:
 I just had a look; if I'm not mistaken, it's not really a streaming
 parser, but rather the ability to read a SEQUENCE of JSON forms from a
 stream.

 This avoids the ordering issue I raised earlier (JSON object fields
 are unordered), but allows you to process the sequence of JSON forms
 asynchronously in different threads (which may introduce it's own
 ordering issues, but at least it's under your control).

 This may be what you need; for example, you could output a series of
 JSON forms describing one high score, and loop reading them one at a
 time.

 However, it won't let you read some complex JSON structure, parsing it
 as it reads. Each form read will be fully-parsed in one step, and
 returned.

 This seems to me to be about the right compromise for JSON.

 The big semantic differences between JSON and XML are 1) JSON objects
 are unordered, and 2) JSON objects are not named (while their fields
 are).

 1) is a headache for anything that mixes processing with reading, as
 the processing is then unordered as well.
 2) is easily worked around by an application, but makes it harder to
 design a general API to invoke processing, and interacts badly with
 1).

 But if you can recast your big JSON object as a series of smaller
 objects, each processed one at a time, a GSON does, you get most of
 the benefit and avoid most of the headaches.

 On Dec 27, 11:20 am, Rmac ry...@me.com wrote:



  Check out GSON... in version 1.6 there is a new very small streaming
  parser.- Hide quoted text -

 - Show quoted text -

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: Which JSON Parser is better

2011-02-22 Thread Sunil Lakhiyani
Gson is batter than other one.
For date : in gson convert it into miliseconds and than parse it.
Store ms in long datatype

On Feb 22, 2011 10:38 PM, Manish Garg mannishga...@gmail.com wrote:

I used gson and it was working fine but in some cases i got
deserialization error or wrong format in case of stroing dates in long
and then parsing them. Jackson doesn't give this error and solving my
problem. Now I am bit confused which one i should used because size of
jackson is more than gson and i do not need all functionality of the
jackson. i need only fromJson function of gson or
mapper.readValue(response, classType) of jackson.

I am also not very sure about the performance of jacson and gson.
Jackson looks bit slow.

On Dec 29 2010, 1:15 am, Bob Kerns r...@acm.org wrote:
 I just had a look; if I'm not mistaken, it's not really a streaming
 parser, but rather the ability to read a SEQUENCE of JSON forms from a
 stream.

 This avoids the ordering issue I raised earlier (JSON object fields
 are unordered), but allows you to process the sequence of JSON forms
 asynchronously in different threads (which may introduce it's own
 ordering issues, but at least it's under your control).

 This may be what you need; for example, you could output a series of
 JSON forms describing one high score, and loop reading them one at a
 time.

 However, it won't let you read some complex JSON structure, parsing it
 as it reads. Each form read will be fully-parsed in one step, and
 returned.

 This seems to me to be about the right compromise for JSON.

 The big semantic differences between JSON and XML are 1) JSON objects
 are unordered, and 2) JSON objects are not named (while their fields
 are).

 1) is a headache for anything that mixes processing with reading, as
 the processing is then unordered as well.
 2) is easily worked around by an application, but makes it harder to
 design a general API to invoke processing, and interacts badly with
 1).

 But if you can recast your big JSON object as a series of smaller
 objects, each processed one at a time, a GSON does, you get most of
 the benefit and avoid most of the headaches.

 On Dec 27, 11:20 am, Rmac ry...@me.com wrote:



  Check out GSON... in version 1.6 there is a new very small streaming
  parser.- Hide quoted text -

 - Show quoted text -

--
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Which JSON Parser is better

2010-12-28 Thread Bob Kerns
I just had a look; if I'm not mistaken, it's not really a streaming
parser, but rather the ability to read a SEQUENCE of JSON forms from a
stream.

This avoids the ordering issue I raised earlier (JSON object fields
are unordered), but allows you to process the sequence of JSON forms
asynchronously in different threads (which may introduce it's own
ordering issues, but at least it's under your control).

This may be what you need; for example, you could output a series of
JSON forms describing one high score, and loop reading them one at a
time.

However, it won't let you read some complex JSON structure, parsing it
as it reads. Each form read will be fully-parsed in one step, and
returned.

This seems to me to be about the right compromise for JSON.

The big semantic differences between JSON and XML are 1) JSON objects
are unordered, and 2) JSON objects are not named (while their fields
are).

1) is a headache for anything that mixes processing with reading, as
the processing is then unordered as well.
2) is easily worked around by an application, but makes it harder to
design a general API to invoke processing, and interacts badly with
1).

But if you can recast your big JSON object as a series of smaller
objects, each processed one at a time, a GSON does, you get most of
the benefit and avoid most of the headaches.

On Dec 27, 11:20 am, Rmac ry...@me.com wrote:
 Check out GSON... in version 1.6 there is a new very small streaming
 parser.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Which JSON Parser is better

2010-12-27 Thread Rmac
Check out GSON... in version 1.6 there is a new very small streaming
parser.

On Dec 27, 1:11 am, ko5tik kpriblo...@yahoo.com wrote:
 On Dec 26, 7:18 pm, Jonathan Foley jonefo...@gmail.com wrote:

  Are you aware of the jackson JSON library, its very fast and has nice
  data binding APIs.

 Yes, I'm aware of it - but it comes with full (although small)  can of
 worms and dependencies attached.
 Right now my games are 130KB and including just parser would blow  it
 - and then there is data binding
 layer.  (well, other parsers are much worse)

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Which JSON Parser is better

2010-12-26 Thread ko5tik


On Dec 25, 11:51 pm, DanH danhi...@ieee.org wrote:
 Until you get up to **at least** 10K of JSON (maybe 1M, depending on
 the overall app size) there's no point in worrying about pull
 parsing.  Reading and parsing the entire JSON file at once will
 increase temporarily the amount of heap used, but it's hardly a blip
 in most environments.

In my game I pull up to 1000 highscore entries from  server (well,not
always
but certainly on first synchronization) and load them from internal
storage -
there is definitely need in pull parsing. I also utilize my own small
data binding
library, and will add pull parsing to it when i get some time.
Everybody is welcome to join the
effort:
https://github.com/ko5tik/jsonserializer


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Which JSON Parser is better

2010-12-26 Thread DanH
The thing is, the standard JSON representations of data are about as
compact as one can get in Java -- unlike XML where the representation
is very inefficient.  In order to read the JSON you'll create most of
the objects used to represent it, so you'll churn through about the
same amount of heap whether you hold onto the representation or not --
the only difference is the high-water-mark, and that's much less
critical than churn in terms of app performance.

On Dec 26, 4:54 am, ko5tik kpriblo...@yahoo.com wrote:
 On Dec 25, 11:51 pm, DanH danhi...@ieee.org wrote:

  Until you get up to **at least** 10K of JSON (maybe 1M, depending on
  the overall app size) there's no point in worrying about pull
  parsing.  Reading and parsing the entire JSON file at once will
  increase temporarily the amount of heap used, but it's hardly a blip
  in most environments.

 In my game I pull up to 1000 highscore entries from  server (well,not
 always
 but certainly on first synchronization) and load them from internal
 storage -
 there is definitely need in pull parsing. I also utilize my own small
 data binding
 library, and will add pull parsing to it when i get some time.
 Everybody is welcome to join the
 effort:https://github.com/ko5tik/jsonserializer

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Which JSON Parser is better

2010-12-26 Thread Jonathan Foley


Are you aware of the jackson JSON library, its very fast and has nice
data binding APIs.

Jonathan


On Dec 26, 5:54 am, ko5tik kpriblo...@yahoo.com wrote:
 On Dec 25, 11:51 pm, DanH danhi...@ieee.org wrote:

  Until you get up to **at least** 10K of JSON (maybe 1M, depending on
  the overall app size) there's no point in worrying about pull
  parsing.  Reading and parsing the entire JSON file at once will
  increase temporarily the amount of heap used, but it's hardly a blip
  in most environments.

 In my game I pull up to 1000 highscore entries from  server (well,not
 always
 but certainly on first synchronization) and load them from internal
 storage -
 there is definitely need in pull parsing. I also utilize my own small
 data binding
 library, and will add pull parsing to it when i get some time.
 Everybody is welcome to join the
 effort:https://github.com/ko5tik/jsonserializer

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Which JSON Parser is better

2010-12-26 Thread ko5tik


On Dec 26, 7:18 pm, Jonathan Foley jonefo...@gmail.com wrote:
 Are you aware of the jackson JSON library, its very fast and has nice
 data binding APIs.

Yes, I'm aware of it - but it comes with full (although small)  can of
worms and dependencies attached.
Right now my games are 130KB and including just parser would blow  it
- and then there is data binding
layer.  (well, other parsers are much worse)

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Which JSON Parser is better

2010-12-25 Thread ko5tik
Built in JSON is  adequate, but as every DOM-Kind of parser pretty
memory consuming.
Pull-Parser is really necessary.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Which JSON Parser is better

2010-12-25 Thread JP
Pull parsing is absolutely a favorite in mobile. While I agree with
Jake, one thing to consider is a fundamental conceptual decision that
is baked into the question whether to employ a tree parser or a
streaming parser. Typically, this cannot be optimized away later, and
may drive a fundamental overhaul (refactorization) of the app.

In my experience, parsing non trivial data streams (JSON, XML, others)
in a mobile environment needs to have the following characteristics:
1. Maintains a small memory footprint, as mentioned
2. Allows to immediately draw data as the parser moves along. This is
important due to the often slow connections - it keeps users
entertained (this falls into the subjective user satisfaction
category) and informed
3. Can be instantly stopped at any point. When users start seeing the
data unfold (see 2.), users may want to stop the potentially long data
pull. The app needs to be able to respond to this request on the spot


On Dec 25, 7:37 am, ko5tik kpriblo...@yahoo.com wrote:
 Built in JSON is  adequate, but as every DOM-Kind of parser pretty
 memory consuming.
 Pull-Parser is really necessary.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Which JSON Parser is better

2010-12-25 Thread Bob Kerns
Because objects in JSON are unordered (An object is an unordered set
of name/value pairs.), a pull parser is going to have to work a bit
differently.

One way to make it work is to pass in a map of continuations, or an
object or class with methods selected with reflection.

However, I have reservations about the whole pull-parsing paradigm
when combined with unordered objects, because if you have dependencies
in the processing of the fields, it may appear to work OK -- until the
order changes, perhaps with a server reboot, or unrelated code change,
or anything at all.

This sort of situation can make for bugs that are VERY hard to test
for and VERY hard to debug -- and often, VERY hard to fix.

But if you approach it with the right discipline...

Of course, a downside is that discipline might entail designing the
JSON payload to use arrays instead of objects.  This would impose a
readability and upward compatibility cost on the content. (But on the
other hand, it'd be a bit more compact and efficient).

Still, I think it is prudent to not consider a pull parser for JSON
until and unless you have a demonstrated performance problem to solve.

The issue doesn't arise to the same degree in XML, because at the
level of XML itself, order is meaningful and preserved, even if a
higher level may consider order unimportant. XML generators have the
ability to control the order of elements; JSON generators do not.

On Dec 25, 7:37 am, ko5tik kpriblo...@yahoo.com wrote:
 Built in JSON is  adequate, but as every DOM-Kind of parser pretty
 memory consuming.
 Pull-Parser is really necessary.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Which JSON Parser is better

2010-12-25 Thread Brill Pappin
I think the thing to remember is that it's YAGNI until you have a case
for changing it.
Just use the Json package in the android sdk, until you find you need
to change things for some reason.

Your spending a lot if time worrying about something you likely don't
need to worry about. Get coding and if you have a problem with the
lib, only then worry about what else you can do.

My 2 cents...
- Brill

On Dec 23, 1:59 am, cool.manish mannishga...@gmail.com wrote:
 Hi Brill,

 I am sorry, I didn't get your point. I am very new in this field and
 don't know, if gson is a binary format then how will it effect?

 As per my knowledge about gson, I can give one String to it which has
 JSON data in it, it will parse it and then i can search for a
 particular object or value.

 Is your meaning of saying One built into the platform is it that I
 should use JSONTokenizer or whatever Android is providing me?

 On Dec 23, 11:51 am, Brill Pappin br...@pappin.ca wrote:



  Isn't gson a binary format?

  MongoDB talks about using GSON over JSON.

  IMO I'd simply use the one built into the platform.

  - Brill Pappin

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Which JSON Parser is better

2010-12-25 Thread DanH
Until you get up to **at least** 10K of JSON (maybe 1M, depending on
the overall app size) there's no point in worrying about pull
parsing.  Reading and parsing the entire JSON file at once will
increase temporarily the amount of heap used, but it's hardly a blip
in most environments.

On Dec 25, 11:14 am, JP joachim.pfeif...@gmail.com wrote:
 Pull parsing is absolutely a favorite in mobile. While I agree with
 Jake, one thing to consider is a fundamental conceptual decision that
 is baked into the question whether to employ a tree parser or a
 streaming parser. Typically, this cannot be optimized away later, and
 may drive a fundamental overhaul (refactorization) of the app.

 In my experience, parsing non trivial data streams (JSON, XML, others)
 in a mobile environment needs to have the following characteristics:
 1. Maintains a small memory footprint, as mentioned
 2. Allows to immediately draw data as the parser moves along. This is
 important due to the often slow connections - it keeps users
 entertained (this falls into the subjective user satisfaction
 category) and informed
 3. Can be instantly stopped at any point. When users start seeing the
 data unfold (see 2.), users may want to stop the potentially long data
 pull. The app needs to be able to respond to this request on the spot

 On Dec 25, 7:37 am, ko5tik kpriblo...@yahoo.com wrote:

  Built in JSON is  adequate, but as every DOM-Kind of parser pretty
  memory consuming.
  Pull-Parser is really necessary.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Which JSON Parser is better

2010-12-24 Thread DanH
JSON is blazingly simple.  You can write your own parser in a day
using about 600 lines of code.  (Another 300 lines of code and maybe 3
hours to write the encoder end.)  It should be possible to examine the
versions you're considering and see which appears to be more
professionally written and better tuned to your needs.  Storage
requirements for any well-written parsers should be about the same.

On Dec 23, 12:43 am, cool.manish mannishga...@gmail.com wrote:
 Hi All,

 I want to use some JSON parser in my application. I get to know about
 lots of available JSON parser like Android default org.json library,
 JSONTokenizer, gson, jackson etc.

 Is there any benifit of using gson rather than Android default parser?

 I am bit confused which one of them is better keeping in mind their
 usability and apk size.

 Regards,
 Manish

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Which JSON Parser is better

2010-12-24 Thread Jake Basile
The JSON library built into Android (org.json) should be more than efficient 
for your needs on a mobile device. If there are inefficiencies in it, they 
almost certainly won't be large enough to cause a visible slowdown in your 
app unless you are transmitting a drastic amount of information over JSON - 
which isn't really what it's for.* *In addition, by using the built in 
library you can be assured that there will be fewer bugs than in something 
you write yourself simply because the included library is older and more 
widely deployed. Lastly, you save yourself the time, however minimal, of 
re-inventing the wheel.

Before you write your own JSON parser, I'd just write your app with the 
included code. Later on, if you notice performance problems you can then 
measure and eliminate them no matter where they originate. Pre-optimizing is 
a dangerous game to play.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Which JSON Parser is better

2010-12-22 Thread Brill Pappin
Isn't gson a binary format?

MongoDB talks about using GSON over JSON.

IMO I'd simply use the one built into the platform.

- Brill Pappin

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: Which JSON Parser is better

2010-12-22 Thread cool.manish
Hi Brill,

I am sorry, I didn't get your point. I am very new in this field and
don't know, if gson is a binary format then how will it effect?

As per my knowledge about gson, I can give one String to it which has
JSON data in it, it will parse it and then i can search for a
particular object or value.

Is your meaning of saying One built into the platform is it that I
should use JSONTokenizer or whatever Android is providing me?

On Dec 23, 11:51 am, Brill Pappin br...@pappin.ca wrote:
 Isn't gson a binary format?

 MongoDB talks about using GSON over JSON.

 IMO I'd simply use the one built into the platform.

 - Brill Pappin

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en