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

Param variables appears multiple times in the serialized JSON format #1139

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

Param variables appears multiple times in the serialized JSON format #1139

atikj opened this issue Oct 16, 2024 · 0 comments

Comments

@atikj
Copy link

atikj commented Oct 16, 2024

Consider below ksy file
`meta:
id: abc2
endian: le
title: Project specific packets

params:

  • id: project_id
    type: u2

seq:

  • id: packet
    type:
    switch-on: project_id
    cases:
    1: project_id_1`

When the binary data is serialized into JSON, we have observed that project_id field appears as member of sequence along with property packet? Also in the Kaitai generated files of GoLanguage, this params appears as a member variable of abc2 struct as well.

As per my understanding, this is default behavior of kaitai. In Kaitai Struct, when you define parameters in your KSY file, these parameters are often included as member variables in the generated classes (Go structs or Java classes). This is because the parameters are essential for the parsing logic and are treated as part of the object’s state. When these objects are serialized into JSON, the parameters appear as member variables.

Kindly confirm above behavior.
How can we remove the appearance of params as member variables? We dont want that params to be appear as field in the serialized JSON. Is there any better approach to achieve that?

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

No branches or pull requests

1 participant