将JSON对象的字符串编组到JSON数组中

This question is related to this solved one (i.e. similar code but it is a different question. The output of the code below is a series of json objects, but taken together they are not json (at least in the format that I need it). i.e. The objects are not in an array, and there is not a comma between them. How can I return comma separated objects in an array?

buffer := new(bytes.Buffer)
for _, jsonRawMessage := range sliceOfJsonRawMessages{
    if err := json.Compact(buffer, jsonRawMessage); err != nil{
        fmt.Println("error")

    }

}
output, _ := json.Marshal(buffer.String())
w.Header().Set("Content-Type", contentTypeJSON)

w.Write(output)

Output (2 distinct json objects but there's actually a lot more)

{
    "Dir": "/usr/local/go/src/bytes",
    "ImportPath": "bytes",
    "Name": "bytes",
    "Doc": "Package bytes implements functions for the manipulation of byte slices.",
    "Target": "/usr/local/go/pkg/darwin_amd64/bytes.a",
    "Goroot": true,
    "Standard": true,
    "Root": "/usr/local/go",
    "GoFiles": [
        "buffer.go",
        "bytes.go",
        "bytes_decl.go",
        "reader.go"
    ],
    "IgnoredGoFiles": [
        "equal_test.go"
    ],
    "Imports": [
        "errors",
        "io",
        "unicode",
        "unicode/utf8"
    ],
    "Deps": [
        "errors",
        "io",
        "runtime",
        "sync",
        "sync/atomic",
        "unicode",
        "unicode/utf8",
        "unsafe"
    ],
    "TestGoFiles": [
        "export_test.go"
    ],
    "XTestGoFiles": [
        "buffer_test.go",
        "bytes_test.go",
        "compare_test.go",
        "example_test.go",
        "reader_test.go"
    ],
    "XTestImports": [
        "bytes",
        "encoding/base64",
        "fmt",
        "io",
        "io/ioutil",
        "math/rand",
        "os",
        "reflect",
        "runtime",
        "sort",
        "sync",
        "testing",
        "unicode",
        "unicode/utf8"
    ]
}{
    "Dir": "/usr/local/go/src/errors",
    "ImportPath": "errors",
    "Name": "errors",
    "Doc": "Package errors implements functions to manipulate errors.",
    "Target": "/usr/local/go/pkg/darwin_amd64/errors.a",
    "Goroot": true,
    "Standard": true,
    "Root": "/usr/local/go",
    "GoFiles": [
        "errors.go"
    ],
    "Deps": [
        "runtime",
        "unsafe"
    ],
    "XTestGoFiles": [
        "errors_test.go",
        "example_test.go"
    ],
    "XTestImports": [
        "errors",
        "fmt",
        "testing",
        "time"
    ]
}

You can concatenate them yourself:

var buff bytes.Buffer
buff.WriteByte('[')

for i, j := range jsons {
    if i != 0 {
      buff.WriteByte(',')
    }
    buff.Write([]byte(j))
}
buff.WriteByte(']')

you can then use json.Indent or json.Compact if you need to clean up the json further.

var output bytes.Buffer
err = json.Indent(&output, buff.Bytes(), "", "  ")
// or json.Compact(&output, buff.Bytes())
if err != nil {
    // something wrong with the json
}