-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Items are stringified and parsed twice on browser platform #114
Comments
cc @GillesC |
@JeffBerman If this is still an issue I can look into it :) |
I have pasted a wrong comment earlier, which I have taken off. I confirm yes that we are double parsing and stringifying. Fixing it might mean, no backward compatibility. cc @GillesC |
Hi, it is still an issue. :) For us at least, a lack of backward compatibility isn't an issue, as we only use the browser platform during app development and the issue only occurs on that platform. Thanks! |
Understood. Fix look easy and I will add it to wip branch. @GillesC suggest though whether we merge to a minor or major release? Unless someone uses browser platform for production this might not be an issue.. |
Thank you, Alok! |
Hi, I'm using it on the browser platform and I was was wondering if this is the reason why the values get registered with "\" at the beginning and \"" at the end? |
@J3m5 you are spot on! So, long and we haven't fixed it. I'm sorry. Would you be able to give a PR? |
I'll take a look, do you have any idea why the values are parsed and stringified twice ? I quickly went through the source code but I didn't see anything obvious. |
Are there any news about this issue? |
TBH, I switched to Capacitor since then, there is an official plugin for this. |
When using NativeStorage.setItem() on the browser platform, the object is stringified twice. When using NativeStorage.getItem(), it is parsed twice. While odd, this doesn't actually hurt anything when using NativeStorage to do both actions.
It breaks, however, when using NativeStorage to retrieve an item that was originally written by window.localStorage. In my case, I'm upgrading our app, which previously used localStorage, to use NativeStorage. At app startup, the code uses NativeStorage to retrieve some data; if it exists, it knows it came from native storage and goes on its way. If it doesn't exist in native storage, then it converts it by retrieving it from local storage and writing it out to native storage. This works great on a phone, but fails when run in the browser because on a browser local storage is used behind the scenes, and the double-parse causes an error (because the data was originally written with only one stringify).
I left this as a comment on closed issue #47, but then thought it might have no visibility there.
The text was updated successfully, but these errors were encountered: