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