Skip to content

How to query JSON including literal field/values in the output? #249

Closed
@natenho

Description

I'm building a JSON transformation feature using GJSON and the use case is to parse an input and generate a transformed JSON, but also including extra fields (i.e. fields/values not present in the source JSON). Is that possible with GJSON?
Example:

Given the following input (from GJSON playground):

{
  "name": {"first": "Tom", "last": "Anderson"}
}

When the input is {name.last,"foo":name.first}, the result is
{"last":"Anderson","foo":"Tom"}

But when the input is {name.last,"foo":"bar"}, the result is:
{"last":"Anderson"}

I expected that the result would be
{"last":"Anderson","foo":"bar"}

Is there any way to achieve that?

Activity

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

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