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

Automatically allow struct access by json tags #108

Merged
merged 1 commit into from
Nov 10, 2024
Merged

Conversation

scudette
Copy link
Contributor

This fixes issues where non-dicts structs are injected into VQL output. If a custom struct has both fields and json tags which are not consistent, then the user sees the json tags as the struct is serialized. But then when they attempt to access the field by these this will fail because the struct name is actually different:

type Foo struct {
SrcIP string json:"src_ip"
}

Accessing the field like X.src_ip was failing because the struct does not really have a field src_ip - even though it looks like it because the json serialized data does!

This fixes issues where non-dicts structs are injected into VQL
output. If a custom struct has both fields and json tags which are not
consistent, then the user sees the json tags as the struct is
serialized. But then when they attempt to access the field by these
this will fail because the struct name is actually different:

type Foo struct {
  SrcIP string `json:"src_ip"`
}

Accessing the field like `X.src_ip` was failing because the struct
does not really have a field `src_ip` - even though it looks like it
because the json serialized data does!
@scudette scudette merged commit 207766c into master Nov 10, 2024
3 checks passed
@scudette scudette deleted the associative branch November 10, 2024 07:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant