MarshalJSON should be defined on T not *T
Otherwise "%v" format would be used by json.Marshal(T).
This commit is contained in:
+1
-1
@@ -38,7 +38,7 @@ func (src *BackendKeyData) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *BackendKeyData) MarshalJSON() ([]byte, error) {
|
||||
func (src BackendKeyData) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
ProcessID uint32
|
||||
|
||||
@@ -144,7 +144,7 @@ func (src *Bind) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *Bind) MarshalJSON() ([]byte, error) {
|
||||
func (src Bind) MarshalJSON() ([]byte, error) {
|
||||
formattedParameters := make([]map[string]string, len(src.Parameters))
|
||||
for i, p := range src.Parameters {
|
||||
if p == nil {
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ func (src *BindComplete) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *BindComplete) MarshalJSON() ([]byte, error) {
|
||||
func (src BindComplete) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
}{
|
||||
|
||||
@@ -51,7 +51,7 @@ func (src *Close) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *Close) MarshalJSON() ([]byte, error) {
|
||||
func (src Close) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
ObjectType string
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ func (src *CloseComplete) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *CloseComplete) MarshalJSON() ([]byte, error) {
|
||||
func (src CloseComplete) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
}{
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ func (src *CommandComplete) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *CommandComplete) MarshalJSON() ([]byte, error) {
|
||||
func (src CommandComplete) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
CommandTag string
|
||||
|
||||
@@ -59,7 +59,7 @@ func (src *CopyBothResponse) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *CopyBothResponse) MarshalJSON() ([]byte, error) {
|
||||
func (src CopyBothResponse) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
ColumnFormatCodes []uint16
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ func (src *CopyData) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *CopyData) MarshalJSON() ([]byte, error) {
|
||||
func (src CopyData) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
Data string
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ func (src *CopyDone) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *CopyDone) MarshalJSON() ([]byte, error) {
|
||||
func (src CopyDone) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
}{
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ func (src *CopyFail) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *CopyFail) MarshalJSON() ([]byte, error) {
|
||||
func (src CopyFail) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
Message string
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ func (src *CopyInResponse) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *CopyInResponse) MarshalJSON() ([]byte, error) {
|
||||
func (src CopyInResponse) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
ColumnFormatCodes []uint16
|
||||
|
||||
@@ -60,7 +60,7 @@ func (src *CopyOutResponse) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *CopyOutResponse) MarshalJSON() ([]byte, error) {
|
||||
func (src CopyOutResponse) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
ColumnFormatCodes []uint16
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ func (src *DataRow) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *DataRow) MarshalJSON() ([]byte, error) {
|
||||
func (src DataRow) MarshalJSON() ([]byte, error) {
|
||||
formattedValues := make([]map[string]string, len(src.Values))
|
||||
for i, v := range src.Values {
|
||||
if v == nil {
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ func (src *Describe) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *Describe) MarshalJSON() ([]byte, error) {
|
||||
func (src Describe) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
ObjectType string
|
||||
|
||||
@@ -25,7 +25,7 @@ func (src *EmptyQueryResponse) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *EmptyQueryResponse) MarshalJSON() ([]byte, error) {
|
||||
func (src EmptyQueryResponse) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
}{
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ func (src *Execute) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *Execute) MarshalJSON() ([]byte, error) {
|
||||
func (src Execute) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
Portal string
|
||||
|
||||
@@ -25,7 +25,7 @@ func (src *Flush) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *Flush) MarshalJSON() ([]byte, error) {
|
||||
func (src Flush) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
}{
|
||||
|
||||
@@ -57,7 +57,7 @@ func (src *FunctionCallResponse) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *FunctionCallResponse) MarshalJSON() ([]byte, error) {
|
||||
func (src FunctionCallResponse) MarshalJSON() ([]byte, error) {
|
||||
var formattedValue map[string]string
|
||||
var hasNonPrintable bool
|
||||
for _, b := range src.Result {
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ func (src *NoData) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *NoData) MarshalJSON() ([]byte, error) {
|
||||
func (src NoData) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
}{
|
||||
|
||||
@@ -57,7 +57,7 @@ func (src *NotificationResponse) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *NotificationResponse) MarshalJSON() ([]byte, error) {
|
||||
func (src NotificationResponse) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
PID uint32
|
||||
|
||||
@@ -55,7 +55,7 @@ func (src *ParameterDescription) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *ParameterDescription) MarshalJSON() ([]byte, error) {
|
||||
func (src ParameterDescription) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
ParameterOIDs []uint32
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ func (src *ParameterStatus) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (ps *ParameterStatus) MarshalJSON() ([]byte, error) {
|
||||
func (ps ParameterStatus) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
Name string
|
||||
|
||||
@@ -73,7 +73,7 @@ func (src *Parse) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *Parse) MarshalJSON() ([]byte, error) {
|
||||
func (src Parse) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
Name string
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ func (src *ParseComplete) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *ParseComplete) MarshalJSON() ([]byte, error) {
|
||||
func (src ParseComplete) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
}{
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ func (src *PasswordMessage) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *PasswordMessage) MarshalJSON() ([]byte, error) {
|
||||
func (src PasswordMessage) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
Password string
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ func (src *PortalSuspended) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *PortalSuspended) MarshalJSON() ([]byte, error) {
|
||||
func (src PortalSuspended) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
}{
|
||||
|
||||
@@ -39,7 +39,7 @@ func (src *Query) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *Query) MarshalJSON() ([]byte, error) {
|
||||
func (src Query) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
String string
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ func (src *ReadyForQuery) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *ReadyForQuery) MarshalJSON() ([]byte, error) {
|
||||
func (src ReadyForQuery) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
TxStatus string
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ func (src *RowDescription) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *RowDescription) MarshalJSON() ([]byte, error) {
|
||||
func (src RowDescription) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
Fields []FieldDescription
|
||||
|
||||
@@ -56,7 +56,7 @@ func (src *SASLInitialResponse) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *SASLInitialResponse) MarshalJSON() ([]byte, error) {
|
||||
func (src SASLInitialResponse) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
AuthMechanism string
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ func (src *SASLResponse) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *SASLResponse) MarshalJSON() ([]byte, error) {
|
||||
func (src SASLResponse) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
Data string
|
||||
|
||||
+1
-1
@@ -89,7 +89,7 @@ func (src *StartupMessage) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *StartupMessage) MarshalJSON() ([]byte, error) {
|
||||
func (src StartupMessage) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
ProtocolVersion uint32
|
||||
|
||||
@@ -25,7 +25,7 @@ func (src *Sync) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *Sync) MarshalJSON() ([]byte, error) {
|
||||
func (src Sync) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
}{
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ func (src *Terminate) Encode(dst []byte) []byte {
|
||||
}
|
||||
|
||||
// MarshalJSON implements encoding/json.Marshaler.
|
||||
func (src *Terminate) MarshalJSON() ([]byte, error) {
|
||||
func (src Terminate) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(struct {
|
||||
Type string
|
||||
}{
|
||||
|
||||
Reference in New Issue
Block a user