Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The json object which you are receiving from the server contains <a href="http://www.asp.net/web-api/overview/formats-and-model-binding/json-and-xml-serialization#handling_circular_object_references">Circular References</a>. Before using the object you should have to first remove all the <code>$ref</code> properties from the object, means in place of <code>$ref : "1"</code> you have to put the object which this link points. </p> <p><em>In your case may be it is pointing to the User's object whose id is 1</em> </p> <p>For this you should check out <a href="https://github.com/douglascrockford/JSON-js">Douglas Crockfords Plugin on github</a>.There is a cycle.js which can do the job for you.</p> <p>or you can use the following code (not tested) :</p> <pre><code>function resolveReferences(json) { if (typeof json === 'string') json = JSON.parse(json); var byid = {}, // all objects by id refs = []; // references to objects that could not be resolved json = (function recurse(obj, prop, parent) { if (typeof obj !== 'object' || !obj) // a primitive value return obj; if ("$ref" in obj) { // a reference var ref = obj.$ref; if (ref in byid) return byid[ref]; // else we have to make it lazy: refs.push([parent, prop, ref]); return; } else if ("$id" in obj) { var id = obj.$id; delete obj.$id; if ("$values" in obj) // an array obj = obj.$values.map(recurse); else // a plain object for (var prop in obj) obj[prop] = recurse(obj[prop], prop, obj) byid[id] = obj; } return obj; })(json); // run it! for (var i=0; i&lt;refs.length; i++) { // resolve previously unknown references var ref = refs[i]; ref[0][ref[1]] = byid[refs[2]]; // Notice that this throws if you put in a reference at top-level } return json; } </code></pre> <p>Let me know if it helps !</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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