Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deep recursion order is inconsistent #43

Open
robross0606 opened this issue Aug 20, 2021 · 0 comments
Open

Deep recursion order is inconsistent #43

robross0606 opened this issue Aug 20, 2021 · 0 comments

Comments

@robross0606
Copy link

robross0606 commented Aug 20, 2021

With input like this:

{
  "firstName": "John",
  "lastName" : "doe",
  "age"      : 26,
  "address"  : {
    "streetAddress": "naist street",
    "city"         : "Nara",
    "postalCode"   : "630-0192"
  },
  "phoneNumbers": [
    {
      "type"  : "iPhone",
      "number": "0123-4567-8888",
      "third": {
          "deep": "third level"
      }
    },
    {
      "type"  : "home",
      "number": "0123-4567-8910"
    }
  ],
  "last": "this should be last"
}

And a query of:

$..*@string()

You would expect to get this for output paths:

[
  "$['firstName']",
  "$['lastName']",
  "$['address']['streetAddress']",
  "$['address']['city']",
  "$['address']['postalCode']",
  "$['phoneNumbers'][0]['type']",
  "$['phoneNumbers'][0]['number']",
  "$['phoneNumbers'][0]['third']['deep']",
  "$['phoneNumbers'][1]['type']",
  "$['phoneNumbers'][1]['number']",
  "$['last']"
]

Instead, you get this:

[
  "$['firstName']",
  "$['lastName']",
  "$['last']",
  "$['address']['streetAddress']",
  "$['address']['city']",
  "$['address']['postalCode']",
  "$['phoneNumbers'][0]['type']",
  "$['phoneNumbers'][0]['number']",
  "$['phoneNumbers'][0]['third']['deep']",
  "$['phoneNumbers'][1]['type']",
  "$['phoneNumbers'][1]['number']"
]

At first I thought it was doing "breadth first" instead of "depth first" recursion, but this isn't consistent either. It does all the first level items "breadth first" but then does nested data "depth first". Note where "$['phoneNumbers'][0]['third']['deep']" appears in the list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant