title: How create JSON string with field name
body: <p>In my application, Asp web service returns JSON with object name called <code>'d'</code> so I access that <code>'d'</code> object the in the application as follows,</p>
  
  <p><a href="https://i.stack.imgur.com/0Z5qM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0Z5qM.png" alt="enter image description here"></a></p>
  
  <pre><code>GetBranchOrRegionDataSourceSuccess: function (result, status, init) {
      "use strict";
      var regions = JSON.parse(result.d);
  }
  </code></pre>
  
  <p>I called this function inside the Ajax success call.</p>
  
  <p>Now the problem is I have Jquery function called <code>searchLocations</code>, Inside that function, I need to call this function. and need to pass the parameters. </p>
  
  <p>I tried like this,</p>
  
  <pre><code>var jsonResult = JSON.stringify({'d':result});
    this.GetBranchOrRegionDataSourceSuccess(jsonResult,"Success", true); //here I need to call the function
  </code></pre>
  
  <p>this is my complete function. </p>
  
  <pre><code>function searchName(prov,tree) {
    var result = [];
  
    let searchKey = new RegExp(prov, "i");
  
    var objects = JSON.parse(json);
    for (obj of objects) {
      if (obj.Name.match(searchKey)) {
  
        result.push(obj); 
  
      } else {
        var toAdd = {"Id": obj.Id, "Name": obj.Name, "Branches": []};
        for (branch of obj.Branches) {
          if (branch.Name.match(searchKey)) {
            toAdd.Branches.push(branch);
          }
        }
        if (toAdd.Branches.length) {
          result.push(toAdd);
        }
      }
    }
  
    var jsonResult = JSON.stringify({'d':result});
    this.GetBranchOrRegionDataSourceSuccess(jsonResult,"Success", true); //here I need to call the function
  
  }
  </code></pre>
  
  <p>But it makes error inside <code>GetBranchOrRegionDataSourceSuccess</code> on this line <code>var regions = JSON.parse(result.d);</code> How can I pass the result with <code>'d'</code> object name</p>