title: JSON Multiple Object Creation with ASP.NET Web Service
body: <p>Two related ASP.NET Web Service JSON questions here. I'm using a N-tier designed ASP.NET 2.0  application.</p>
  
  <hr>
  
  <p>Question 1:<br />
  I am trying to get my ASP.NET web service to generate a multiple object JSON response where each object has multiple objects returned. I'm not sure if I am explaining that properly, so here is an example of what I am looking for.</p>
  
  <pre><code>[
      {"id":1, "CommentDataElement": "Value",
          "OldData":{ "Description": "ABC", "Status": "0" },
          "NewData":{ "ShortText": "Text here", "LongText": "More text here" }
      },
      {"id":2, "CommentDataElement": "Value",
          "OldData":{ "Description": "DEF", "Status": "1" },
          "NewData":{ "ShortText": "Text here", "LongText": "More text here" }
      },
      {"id":3, "CommentDataElement": "Value",
          "OldData":{ "Description": "GHI", "Status": "2" }
      },
      {"id":4, "CommentDataElement": "Value",
          "NewData":{ "ShortText": "Text here", "LongText": "More text here" }
      }
  ]
  </code></pre>
  
  <p><code>id</code>'s 1 and 2 have both <code>Old</code> and <code>New</code> datasets, while <code>id</code> 3 only has an <code>Old</code> dataset and <code>id</code> 4 only has a <code>New</code> dataset.</p>
  
  <p>I would then use jQuery to handle this response. And based on the existence of the <code>Old</code> and <code>New</code> datasets, I would generate the proper page elements.</p>
  
  <p>The source of the <code>OldData</code> and <code>NewData</code> are in two different tables. So is this possible to do?</p>
  
  <hr>
  
  <p>Question 2:<br />
  In addition, is it possible to have an ASP.NET web service return a JSON string with two different object structures? Example.</p>
  
  <pre><code>[
      {...same as above, just cut out for brevity...}
      {"id":4, "CommentDataElement": "Value",
          "NewData":{ "ShortText": "Text here", "LongText": "More text here" }
      },
      {"Count":"100"}
  ]
  </code></pre>
  
  <p>Basically what I want to do, is make one request to the server, get my truncated dataset (based on paging, say only returning 20 records of the full set) and get the full record set count so that I can generate my page numbers (pagination). On my Data Access Layer, is it possible to use a return statement for the record set and an <code>OUTPUT</code> parameter for the full count? Just a thought.</p>
  
  <hr>
  
  <p>I'm pretty sure that the JSON that I have written here is not proper. Please feel free to updated as you see fit. Any help is appreciated! Thanks!</p>