grevory / angular-local-storage

An AngularJS module that gives you access to the browsers local storage with cookie fallback
Other
2.83k stars 585 forks source link

Service won't store objects #301

Open cabstool opened 8 years ago

cabstool commented 8 years ago

I get a JSON stringify error when attempting to store any object: error converting circular reference. I'm 100% sure my object(s) do not have circular references.

grevory commented 8 years ago

Is there any way you can provide more detail for reference? Is anyone else experiencing this issue?

cabstool commented 8 years ago

I'm using Breeze and Angular to get an entity object from my backend. The object has no references to itself or any other object at all. When I call localStorageService.set("name", object) I get the JSON.stringify error saying that it cannot convert an object containing a circular reference...

cabstool commented 8 years ago

here is my client side object i'm attempting to store:

{ "$id": "1", "$type": "mydomain.Models.Location, mydomain", "Zip": "99999", "City": "city", "State": "state" },

it's a Breeze entity object which came over from my Breeze server.....

cabstool commented 8 years ago

Hi Gregory,

Any progress on this bug? Thanks.

On Thu, Mar 24, 2016 at 1:14 PM, Gregory Pike notifications@github.com wrote:

Is there any way you can provide more detail for reference? Is anyone else experiencing this issue?

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/grevory/angular-local-storage/issues/301#issuecomment-200955517

grevory commented 8 years ago

No, I am not working on bugs at the moment. Feel free to submit a PR.

akanshgulati commented 8 years ago

@cabstool The current work around for this is to stringify the object. Once you want to get the object, there is no need of parsing the content. It automatically, gives you object.