zeroshade commented on a change in pull request #11359: URL: https://github.com/apache/arrow/pull/11359#discussion_r741363090
########## File path: go/arrow/array/binary.go ########## @@ -117,6 +118,21 @@ func (a *Binary) setData(data *Data) { } } +func (a *Binary) getOneForMarshal(i int) interface{} { + if a.IsNull(i) { + return nil + } + return a.Value(i) +} + +func (a *Binary) MarshalJSON() ([]byte, error) { + vals := make([]interface{}, a.Len()) + for i := 0; i < a.Len(); i++ { + vals[i] = a.getOneForMarshal(i) + } + return json.Marshal(vals) Review comment: From the Go docs on JSON marshalling: https://pkg.go.dev/encoding/json#Marshal > Array and slice values encode as JSON arrays, except that []byte encodes as a base64-encoded string, and a nil slice encodes as the null JSON value. The standard marshalling of byte slices to JSON in go will marshal it to a base64-encoded string. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org