From 4c03ce451f299969fd0fff6212e1f1e696b0f523 Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Sat, 31 Aug 2019 16:00:41 -0500 Subject: [PATCH] Add MarshalJSON for FieldDescription --- row_description.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/row_description.go b/row_description.go index 2745fa43..d9b8c7c9 100644 --- a/row_description.go +++ b/row_description.go @@ -23,6 +23,27 @@ type FieldDescription struct { Format int16 } +// MarshalJSON implements encoding/json.Marshaler. +func (fd FieldDescription) MarshalJSON() ([]byte, error) { + return json.Marshal(struct { + Name string + TableOID uint32 + TableAttributeNumber uint16 + DataTypeOID uint32 + DataTypeSize int16 + TypeModifier int32 + Format int16 + }{ + Name: string(fd.Name), + TableOID: fd.TableOID, + TableAttributeNumber: fd.TableAttributeNumber, + DataTypeOID: fd.DataTypeOID, + DataTypeSize: fd.DataTypeSize, + TypeModifier: fd.TypeModifier, + Format: fd.Format, + }) +} + type RowDescription struct { Fields []FieldDescription }