# JSON in Javascript

**URL:** <https://forum.kirupa.com/t/json-in-javascript/300099>\
**Category:** web dev\
**Created:** [November 16, 2009, 8:06am UTC](https://forum.kirupa.com/t/json-in-javascript/300099 "2009-11-16T08:06:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![riveroaks](https://avatars.discourse-cdn.com/v4/letter/r/90db22/32.png) [@riveroaks](https://forum.kirupa.com/u/riveroaks)\
**Post date:** [November 16, 2009, 8:06am UTC](https://forum.kirupa.com/t/json-in-javascript/300099/1 "2009-11-16T08:06:43Z")

</div>

I’m using a js file from [json.org](http://json.org) which creates and parses JSON object representations in JavaScript. However, it seems that the JSON object only puts object state into the string…does anyone know how I can store the prototype functions as well?

When I get this string back and I need to construct an object I can restore the state just fine…but the state is virtually useless without my accessor/mutator methods…and I have multiple types of objects so I don’t know which is which to go back and individually assign prototype functions…

for example, I could do:

var myObj = JSON.parseJSON( jsonString );  
myObj.method1 = MyClass.prototype.method1;  
myObj.method2 = MyClass.prototype.method2;  
…

But this is tedious, and requires that I store class names as part of all my objects just so that I can use conditional logic to restore the prototype methods that should be there anyways…if anyone can spread some light on this issue I would appreciate it.

Thanks.
