[FAB-16528] marbles private chaincode sync up

This CR is part 2 of porting changes in marbles
private in fabric/integration by FAB-15894 back
to fabric-samples

Signed-off-by: Dongming <dongming@ibm.com>
Change-Id: Ic823bdf4c3c571f43b4700452c50fd4283d35262
This commit is contained in:
Dongming 2019-09-11 12:35:25 -04:00
parent 3fad853c15
commit c13a5ec8f6

View file

@ -523,18 +523,16 @@ func (t *SimpleChaincode) getMarblesByRange(stub shim.ChaincodeStubInterface, ar
return shim.Error(err.Error()) return shim.Error(err.Error())
} }
// Add a comma before array members, suppress it for the first array member // Add a comma before array members, suppress it for the first array member
if bArrayMemberAlreadyWritten == true { if bArrayMemberAlreadyWritten {
buffer.WriteString(",") buffer.WriteString(",")
} }
buffer.WriteString("{\"Key\":")
buffer.WriteString("\"")
buffer.WriteString(queryResponse.Key)
buffer.WriteString("\"")
buffer.WriteString(", \"Record\":") buffer.WriteString(
// Record is a JSON object, so we write as-is fmt.Sprintf(
buffer.WriteString(string(queryResponse.Value)) `{"Key":"%s", "Record":%s}`,
buffer.WriteString("}") queryResponse.Key, queryResponse.Value,
),
)
bArrayMemberAlreadyWritten = true bArrayMemberAlreadyWritten = true
} }
buffer.WriteString("]") buffer.WriteString("]")