5

I am sorry if this is a duplicate, so far I couldn't find the same question.

I have an Object with various methods in my __proto__ member. Let's call the type of this object myObjectType.

Later on I have to do a JSON.stringify(myObjectType). The problem is that then when I build my object from the previous obtained JSON string the type of my Object is plain Object, I lost all the methods I had.

Does any one see why ?

3 Answers 3

4

search google for javascript object serialization.

GSerializer library

Sign up to request clarification or add additional context in comments.

1 Comment

Vm hmm by my effigy.ie.
3

There's no standardized way of incorporating functions into JSON data. You can do something yourself — that is, write your own JSON serializer that incorporates functions according to some convention — but with straight standard JSON you get numbers, strings, booleans, and null, plus of course objects with named properties and arrays. No functions, just data.

1 Comment

1

I'd highly recommend Douglas Crockford's libraries:

https://github.com/douglascrockford/JSON-js

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.