jQuery merge objects and json_encode
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/171251/how-can-i-merge-properties-of-two-javascript-objects-dynamically">How can I merge properties of two JavaScript objects dynamically?</a>  </p>
</blockquote>



<p>I am trying to merge two objects in jQuery.</p>

<p>first object:</p>

<pre><code>var rules1 = {  
    firstname: { required: true, minlength: 3 },
    lastname: { required: true, minlength: 3 }
};
</code></pre>

<p>second object:</p>

<pre><code>var rules2 = {  
    test1: { required: true, minlength: 3 },
    test2: { required: true, minlength: 3 }
};
</code></pre>

<p>I want the result to look like this:</p>

<pre><code>var merged = {  
    firstname: { required: true, minlength: 3 },
    lastname: { required: true, minlength: 3 },
    test1: { required: true, minlength: 3 },
    test2: { required: true, minlength: 3 }
};
</code></pre>

<p>I also need to know how might look like the PHP array for <code>rules1</code>, because this object will be tranformed with <code>json_encode</code> function.</p>
