-
Notifications
You must be signed in to change notification settings - Fork 440
Use Gson to convert javaObject to jsObject #324
Conversation
… object. Convert Java response to JS only once
Thank you! I'll look at it (hopefully) soon. The reason it is what it is, is because of this. Never gave it a second thought to do it differently but your suggestions makes much sense. |
I see. BTW looking at the gist, the last comment there suggest something similar. Give it a look, I'm sure things can do better. And maybe iOS support? |
I may have tried that and had issues, so beware. I use Gson all the time when working on serverside Java so I'm sure your suggestion will be pretty good. We could also take a look at {N}'s http module source. |
I believe things here a bit different - we are not just parsing JSON string, but we need to transform the DataSnapshot Java object back to JSON string and then parsing it (for some reason, Firebase Andrioid library designers chose not to expose the raw data like they did for example for their Unity library, things could have been even faster that way) |
This seems to work really well. I only test with small data structures so don't notice a speed difference, but the conversion looks spot on. Perhaps even fixes an issue or two.. I've added some fallback code in case users updating the plugin don't automatically pull in Gson. But that's a temporary state of course. Just don't feel like a bunch of issues where folks report |
Sounds good :) |
Use Gson to convert javaObject to jsObject
Hi,
We had major performance issues with the plugin when working with medium json files (>50K). It took a couple of seconds (5-8 seconds) to convert the javaObject to javascript one, and it was done twice instead of just one time.
Using Gson (any other library will due I guees) with JSON.parse it take only several (200-300) milliseconds.
This has not tested fully yet and maybe it should be configurable (maybe its having a performance issue on a small size files).
Would like to know why in the first place the conversion was done this way and not with some standard library.
Shay