Note that there are some explanatory texts on larger screens.

plurals
  1. POJavaScriptSerializer RecursionLimitExceed Exception
    primarykey
    data
    text
    <p>I am using <code>JavaScriptSerializer</code> in my application to serialize the object and i encountered an exception while trying to serialize the collection from the data entity. </p> <p>My code,</p> <p>Getting the records from the database.</p> <pre><code>var data = new MadhuDBEntities().ords.ToList(); </code></pre> <p>And I am serilizing the above data using <code>JavaScriptSerializer</code> as follow</p> <pre><code>JavaScriptSerializer jSerializer = new JavaScriptSerializer() { RecursionLimit = 5 }; string json=jSerializer.Serialize(data); </code></pre> <p>And i am getting exception as follow<img src="https://i.stack.imgur.com/UzFgh.png" alt="Recursion Limit Exceeded Exception"></p> <p>I think because the record from the database contains additional values.</p> <p>When serilaize the <code>data</code> without <code>RecursionLimit</code> I get the json data as follow,</p> <p><code>[{"OrderID":1,"EmployeeID":1,"CustomerID":"Madhu","EntityState":2,"EntityKey":{"EntitySetName":"ords","EntityContainerName":"MadhuDBEntities","EntityKeyValues":[{"Key":"OrderID","Value":1}],"IsTemporary":false}},{"OrderID":2,"EmployeeID":1,"CustomerID":"Madhu","EntityState":2,"EntityKey":{"EntitySetName":"ords","EntityContainerName":"MadhuDBEntities","EntityKeyValues":[{"Key":"OrderID","Value":2}],"IsTemporary":false}}]</code></p> <p>In the above actually only the OrderID,EmployeeID and CustomerID are the columns and other are added automatically and i think the problem is also due to them.</p> <p>So Is there any way to serialize the <code>data</code> without the unnecessary terms.</p> <p>Any idea to solve this, but i must use <code>JavaScriptSerializer</code> so tell solution using that.. <img src="https://i.stack.imgur.com/1657W.png" alt="Data Variable"></p> <p>Thanks in advance..</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload