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

Enum representation in decoded data is wrong, I am expecting string value but integer comes #1138

Open
atikj opened this issue Oct 16, 2024 · 0 comments
Labels

Comments

@atikj
Copy link

atikj commented Oct 16, 2024

Consider below defined enum in ksy file where key(integer)-value(string) is defined

enums:
  direction:
    0: reverse
    1: nominal
    2: unknown
    3: spare

When we get the decoded data from Kaitai Compiler Generated go files it shows allowed integer values like 0,1,2,3 but we want its corresponding string value like reverse, nominal, unknown and spare respectively.
As per my understanding, this is default behavior of kaitai. When Kaitai Struct generates code, it typically uses integer values for enum types to maintain efficiency and simplicity in the binary representation. When these values are serialized into JSON, they remain as integers because the generated code does not automatically convert them to their corresponding string representations.

Kindly confirm above behavior. Also suggest some way to convert them to their corresponding string representations using Kaitai.
How to achieve such conversion in Kaitai?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants