Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The <a href="https://github.com/douglascrockford/JSON-js/blob/ad6079cbd8dc362a3cc42e1f97c01aa5ccd48bfe/cycle.js" rel="nofollow">JSON-js cycle.js retrocycle function</a> does not expect a path to have an array index greater than 9. </p> <p>One example path that is not being retrocycled is:</p> <pre><code>$[11]["LegList"][0]["ItenaryList"][0]["Ar"] </code></pre> <p>A similar path that does get retrocycled is:</p> <pre><code>$[9]["LegList"][0]["ItenaryList"][0]["Ar"] </code></pre> <p>If you look at the cycle.js code, you will see that in order for a path to be retrocycled, it must validate against a regular expression.</p> <pre><code>// [...] A PATH is expected to be // reasonably short. A PATH is allowed to belong to a very restricted subset of // Goessner's JSONPath. // So, // var s = '[{"$ref":"$"}]'; // return JSON.retrocycle(JSON.parse(s)); // produces an array containing a single element which is the array itself. var px = /^\$(?:\[(?:\d?|\"(?:[^\\\"\u0000-\u001f]|\\([\\\"\/bfnrt]|u[0-9a-zA-Z]{4}))*\")\])*$/; </code></pre> <p>In the px regular expression, only one digit array indexes are allowed, not two.<br> Since the path does not match the pattern, it will not replace the reference.</p> <p>You could try using a local copy of cycle.js and changing the px regular expression to:</p> <pre><code>var px = /^\$(?:\[(?:\d+|\"(?:[^\\\"\u0000-\u001f]|\\([\\\"\/bfnrt]|u[0-9a-zA-Z]{4}))*\")\])*$/; </code></pre> <p>Note the difference from the previous regular expression: we are saying that we will now allow one or more digits in array indices. This is accomplished by replacing the single ? character after the first d with a +.</p> <p><strong>Edit:</strong> Newer versions of the <a href="https://github.com/douglascrockford/JSON-js/commits/master/cycle.js" rel="nofollow">cycle.js</a> retrocycle function now allow array indices that are greater than 9.</p>
 

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