2
0

decodeJSONB works for text and binary format

This commit is contained in:
Jack Christensen
2016-11-23 12:52:04 -06:00
parent c952d48a5c
commit e96c105b55
2 changed files with 47 additions and 37 deletions
+8 -5
View File
@@ -2087,13 +2087,16 @@ func decodeJSONB(vr *ValueReader, d interface{}) error {
}
bytes := vr.ReadBytes(vr.Len())
if bytes[0] != 1 {
err := ProtocolError(fmt.Sprintf("Unknown jsonb format byte: %x", bytes[0]))
vr.Fatal(err)
return err
if vr.Type().FormatCode == BinaryFormatCode {
if bytes[0] != 1 {
err := ProtocolError(fmt.Sprintf("Unknown jsonb format byte: %x", bytes[0]))
vr.Fatal(err)
return err
}
bytes = bytes[1:]
}
err := json.Unmarshal(bytes[1:], d)
err := json.Unmarshal(bytes, d)
if err != nil {
vr.Fatal(err)
}