pulsarctl icon indicating copy to clipboard operation
pulsarctl copied to clipboard

Handle unknown json fields in responses more gracefully by preserving unknown fields

Open addisonj opened this issue 3 years ago • 0 comments

Overview

When the pulsar broker adds new json fields to certain API calls, like that stats API call, those fields must be explicitly added to the respective structs in this code.

This complicates users being able to see fields in the output until we add explicit support and makes the underlying library out of date.

Solution

By using a library like https://github.com/PerimeterX/marshmallow, we can add an additional extraFields: map[string]interface{} to all the structs and then populate that with any remaining fields from json parsing.

While those fields won't be typed, at the very least can display them and have them exposed. However, we should warn against usage of this as it may break once the fields are added to the top level struct.

addisonj avatar Oct 17 '22 20:10 addisonj