Converting JS String to JSON object
<p>I am trying to construct a JS on the fly for a remote validator function using the validation plugin. but for some reason, it's not converting the JS as an object and is treating it as a string and embedding double quotes.</p>

<p>Ex: </p>

<p>The PHP code I have is:</p>

<pre><code>$remoteUrl = '/test/checkusername';
$remoteValidatorJs = "{url: '". $remoteUrl . "',
                      type: 'post',
                      async:false,
                      dataType: 'html',
                      beforeSend: function(){
                         alert('Validating Form Field');
                       },
                       complete: function(){
                         alert('Completed Validation of Form Field');
                       },
                      dataFilter: function(html) {
                          return html;
                      }
                      }";
$validation[ 'rules' ][ 'Name' ][ 'remote' ] = $remoteValidatorJs;
</code></pre>

<p>How do I frame or convert the JS in <code>$remoteValidatorJs</code> variable so, it eventually looks like the content in the following "remote" section, when the array is printed:</p>

<pre><code>$("#testForm").validate( {
    "rules":{
        "Name":{
            "remote":{
                url: '/test/checkusername',
                type: 'post',
                async:false,
                dataType: 'html',
                beforeSend: function(){
                    alert('Validating Form Field');                     
                },complete: function(){
                    alert('Completed Validation of Form Field');                      
                },
                dataFilter: function(html) {
                    return html;                     
                }
            }
        }
    }
} );
</code></pre>

<p>Thanks,</p>
