JQuery JSON Plugin toJSON a Custom Object
<p>I am using the JQuery json plugin and trying to convert a custom object to JSON using the toJSON function. Here is the object: </p>

<pre><code>function Customer(firstName, lastName, age) {

    Customer.prototype.firstName = firstName;
    Customer.prototype.lastName = lastName;
    Customer.prototype.age = age; 
}
</code></pre>

<p>And here is the $.toJSON applied: </p>

<pre><code>  var customer = new Customer('mohammad', 'azam', 28);

        var a = $.toJSON(customer);
</code></pre>

<p>For some reason "a" is always empty. </p>

<p>But if I use the following code: </p>

<p>var params = new Object();
        params.firstName = 'Mohammad';
        params.lastName = 'Azam';
        params.age = 28;</p>

<p>var a = $.toJSON(params); </p>

<p>then it works fine! </p>

<p>What am I missing when trying to perform toJSON on a custom object. </p>
