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?
Consider below ksy file
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?