Javascript class for enforcing JSON structure
<p>Relatively new to JavaScript, so wondering what is the best approach to achive the below requirement.
I wanted to create JSON object (RPC request object), and need to enforce some structure. As I learn, JS is dynamic language hence I can add any type to an object at any time. But, I like to define a class, which I can populate to construct the JSON request.</p>

<pre><code>var RecReq = {
            ID:{},
            HeaderLevel:{},
            Content:{} //Content object goes here
        },
        HeaderLevel = {
            HeaderID:{},
            Note:{}
        },
        Content = {
            Item: [] //Array of Item goes here
        },
        Item = {
            IDs:[]
        };

    function ReceiveObj() {
        this.RecReq = RecReq,
            this.HeaderLevel = HeaderLevel,
            this.Content = Content,
            this.Item = Item
    };
    return new ReceiveObj();
</code></pre>

<p>I am sure many things wrong with the above code. I don't think the object is created with the arrays initialized.
 On the returned object, I cannot do <code>push()</code> operation to insert an iten onto Content.</p>

<p>How would you approach this. Do you create an object on the fly, or better to define an object which enforces some structure. </p>
