Generating C++ code from JSON schema based on property data types and bit offsets

I’m working on a project where I need to generate C++ code from a JSON schema based on the data types and bit offsets of the properties. Specifically, I need to handle the following scenarios:

Bit Field Properties:
If a property is defined as a bit field with a start offset and a length (e.g., “start”: 1, “length”: 4), I need to generate code that interprets the bits in that range as an integer value.

String Properties:
If a property is defined as a string with a start offset and a length (e.g., “start”: 1, “length”: 4), I need to generate code that interprets the bits in that range as a string value.

The generated code should be independent of the actual values in the JSON schema, as they may change at runtime.
Could someone provide an approach or a library that can help me achieve this? I’m open to using third-party libraries or writing custom code if necessary.