Fixed empty array json bug #1880

This commit is contained in:
Mike Farah
2023-11-23 11:53:18 +11:00
parent 1cf9ecc79d
commit 26effddb8c
2 changed files with 28 additions and 2 deletions
+7 -2
View File
@@ -162,8 +162,13 @@ func (o *CandidateNode) MarshalJSON() ([]byte, error) {
buf.WriteByte('}')
return buf.Bytes(), nil
case SequenceNode:
log.Debugf("MarshalJSON SequenceNode")
err := enc.Encode(o.Content)
log.Debugf("MarshalJSON SequenceNode, %v, len: %v", o.Content, len(o.Content))
var err error
if len(o.Content) == 0 {
buf.WriteString("[]")
} else {
err = enc.Encode(o.Content)
}
return buf.Bytes(), err
default:
err := enc.Encode(nil)