draft-ietf-jsonpath-base icon indicating copy to clipboard operation
draft-ietf-jsonpath-base copied to clipboard

Proposal - Selecting a subset of an object's properties

Open gregsdennis opened this issue 4 years ago • 7 comments

There's no syntax for selecting multiple individual properties from a single object. You either have to select a single property or the entire object.

I would like to propose a "union" or "subselection" syntax (x,y,...) where x, etc. are the properties to be returned. The return value will be an object omitting all properties that are not included in the union declaration.

Using Goessner's example, I could use the path $.store.book[*].(title,price) to select only the title and price of all of the books. It would return

[
  { "title": "Sayings of the Century", "price": 8.95 },
  { "title": "Sword of Honour", "price": 12.99 },
  { "title": "Moby Dick", "price": 8.99 },
  { "title": "The Lord of the Rings", "price": 22.99 },
]

*NOTE I understand the name conflicts with current usage of "union", but that be resolved by changing that usage. I'm struggling to come up with another name.

gregsdennis avatar Jan 05 '21 01:01 gregsdennis