Skip to content

Feature Request: Enhance Syntax for Picking Specific Fields #188

Closed as duplicate

Description

@nitaiaharoni1

Motivation

Ability to select multiple fields from an object in one query.

Current behavior

Currently, to select multiple fields from an object, the user needs to run multiple queries or process the result of a more general query. For example, given the following JSON:

{
  "data": {
    "items": [
      {
        "data": {
          "name": "Apple",
          "color": "red",
          "weight": "150g"
        }
      },
      {
        "data": {
          "name": "Banana",
          "color": "yellow",
          "weight": "120g"
        }
      }
    ]
  }
}

To get the name and color of each item, the user would need to run separate queries for each field: $.data.items[*].data.name and $.data.items[*].data.color.

Desired behavior

The proposal is to introduce a field picking syntax to select multiple fields from an object in one query. For instance, using the following syntax: $.data.items[*].data.{name, color}. With this, the desired output would be:

[
  { name: 'Apple', color: 'red' },
  { name: 'Banana', color: 'yellow' }
]

This would greatly simplify the process of extracting specific fields from JSON data.

Alternatives considered

An alternative could be to continue using multiple queries or to use a more general query and then process the result. However, this can become cumbersome when dealing with large JSON objects or when needing to extract multiple fields.

Activity

  1. callumgare commented on Jun 27, 2023

    @callumgare

    I would also love this! There is already a syntax that is used by a couple of other parses so I think it makes most sense to use that syntax: https://cburgmer.github.io/json-path-comparison/results/parens_notation.html

  2. callumgare commented on Jun 27, 2023

    @callumgare

    Actually it looks like this ticket is a duplicate of #153 so maybe this ticket should be closed and I'll stick my other comment there

  3. 80avin commented on Nov 15, 2025

    @80avin
    Collaborator

    Closing as it is a duplicate ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions