What is the recommended way of serializing a namedtuple to json with the field names retained?
Serializing a namedtuple to json results in only the valu
namedtuple
The jsonplus library provides a serializer for NamedTuple instances. Use its compatibility mode to output simple objects if needed, but prefer the default as it is helpful for decoding back.