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

Support nesting the entire document under a different key #4617

Open
graytaylor0 opened this issue Jun 11, 2024 · 4 comments
Open

Support nesting the entire document under a different key #4617

graytaylor0 opened this issue Jun 11, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@graytaylor0
Copy link
Member

Is your feature request related to a problem? Please describe.
As a user of Data Prepper, my Events look like this

{
 "key-one": "value-one",
 "key-two": "value-two"
}

and I would like them to look like this

{
  "new-key": {
       "key-one": "value-one",
       "key-two": "value-two"
   }
}

Describe the solution you'd like
A way to pass the root (or entire existing document) of an Event to json pointer expression. For example, this could be with /, allowing add_entries to add keys at the highest level with the existing document

Describe alternatives you've considered (Optional)
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@dlvenable
Copy link
Member

I like the idea of using / for the entire event.

@dlvenable dlvenable added enhancement New feature or request and removed untriaged labels Jun 12, 2024
@dlvenable
Copy link
Member

I think if we use /, we can use existing processors such as rename_keys.

@oeyh
Copy link
Collaborator

oeyh commented Jun 12, 2024

In JsonPointer specification, empty string ("") refers to the whole document and / refers to field with empty string as key.

I followed that way and made some changes in #4033 so that JacksonEvent#get("", Object.class) will get you the entire document. Currently "" is not allowed to use in JacksonEvent#put, but we can allow that to put objects to root of the document.

@dlvenable
Copy link
Member

Thanks @oeyh for clarifying that! So then I agree that "" would be the right way to express this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

No branches or pull requests

3 participants