// ===========================================================================================
// constructQueryResponseFromIterator constructs a JSON array containing query results from
// a given result iterator
// ===========================================================================================
constructQueryResponseFromIterator constructs a JSON array containing query results from
a given result iterator
// =========================================================================================== // constructQueryResponseFromIterator constructs a JSON array containing query results from // a given result iterator // ===========================================================================================
func constructQueryResponseFromIterator(resultsIterator shim.StateQueryIteratorInterface) (*bytes.Buffer, error) {
        var buffer bytes.Buffer
        buffer.WriteString("[")
        bArrayMemberAlreadyWritten := false
        for resultsIterator.HasNext() {
                queryResponse, err := resultsIterator.Next()
                if err != nil {
                        return nil, err
                }
                if bArrayMemberAlreadyWritten == true {
                        buffer.WriteString(",")
                }
                buffer.WriteString("{\"Key\":")
                buffer.WriteString("\"")
                buffer.WriteString(queryResponse.Key)
                buffer.WriteString("\"")
                buffer.WriteString(", \"Record\":")
                buffer.WriteString(string(queryResponse.Value))
                buffer.WriteString("}")
                bArrayMemberAlreadyWritten = true
        }
        buffer.WriteString("]")
        return &buffer, nil
}
func constructQueryResponseFromIterator ( resultsIterator shim . StateQueryIteratorInterface ) ( * bytes . Buffer , error ) { var buffer bytes . Buffer buffer . WriteString ( " " ) bArrayMemberAlreadyWritten := false for resultsIterator . HasNext ( ) { queryResponse , err := resultsIterator . Next ( ) if err != nil { return nil , err } if bArrayMemberAlreadyWritten == true { buffer . WriteString ( " " ) } buffer . WriteString ( " \" \" " ) buffer . WriteString ( " \" " ) buffer . WriteString ( queryResponse . Key ) buffer . WriteString ( " \" " ) buffer . WriteString ( " \" \" " ) buffer . WriteString ( string ( queryResponse . Value ) ) buffer . WriteString ( " " ) bArrayMemberAlreadyWritten = true } buffer . WriteString ( " " ) return & buffer , nil }
constructQueryResponseFromIterator constructs a JSON array containing query results from
a given result iterator
constructQueryResponseFromIterator constructs a JSON array containing query results from a given result iterator
// buffer is a JSON array containing QueryResults // Add a comma before array members, suppress it for the first array member // Record is a JSON object, so we write as-is