-
Type: New Feature
-
Resolution: Won't Fix
-
Priority: Minor - P4
-
None
-
Affects Version/s: 0.2.0
-
Component/s: JSON & ExtJSON
-
None
-
Environment:arch/linux 64bit
go: 1.9.2
The Extended JSON encoder does not support encoding arrays and slices by themselves. The decoder does support decoding JSON arrays into slices. Add support for encoding arrays and slices to a JSON array.
(original description below)
What is the best way to build a JSON Producer. My first approach was to make this:
// JSONProducer creates a new JSON producer JSONProducer() runtime.Producer { return runtime.ProducerFunc(func(writer io.Writer, data interface{}) error { valueWriter, _ := bsonrw.NewBSONValueWriter(writer) enc, _ := bson.NewEncoder(valueWriter) return enc.Encode(data) }) }
First this version seems to work. But it leads to two different errors, that I dont understand.
1. runtime error: invalid memory address or nil pointer dereference
2. WriteArray can only write a Array while positioned on a Element or Value but is positioned on a TopLevel