Skip to content

What Path Syntax should I use to turn a nested object into an array of object? #161

@gahoo

Description

@gahoo

Take this json object for example,

{
  "1300014": {
    "code": "1300014",
    "price": 59.18,
    "symbol": "300014",
    "update": "2020/04/15 15:59:54",
  },
  "1300015": {
    "code": "1300015",
    "price": 43.31,
    "symbol": "300015",
    "update": "2020/04/15 15:59:54",
  }
}

And the desired json array is as follow:

[
  {
    "code": "1300014",
    "price": 59.18,
    "symbol": "300014",
    "update": "2020/04/15 15:59:54",
  },
  {
    "code": "1300015",
    "price": 43.31,
    "symbol": "300015",
    "update": "2020/04/15 15:59:54",
  }
]

I thought [*] can do the magic, but It's not. It seems only the first object was selected.

[
  {
    "code": "1300014",
    "price": 59.18,
    "symbol": "300014",
    "update": "2020/04/15 15:59:54",
  }
]

So, the question is what Path Syntax should I use to query all the values of an nested object instead of the first value only.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions