From c13a5ec8f692f4f1521e8b71f5114491b51f6546 Mon Sep 17 00:00:00 2001 From: Dongming Date: Wed, 11 Sep 2019 12:35:25 -0400 Subject: [PATCH] [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 Change-Id: Ic823bdf4c3c571f43b4700452c50fd4283d35262 --- .../go/marbles_chaincode_private.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/chaincode/marbles02_private/go/marbles_chaincode_private.go b/chaincode/marbles02_private/go/marbles_chaincode_private.go index e050e72015..cd52295cfb 100644 --- a/chaincode/marbles02_private/go/marbles_chaincode_private.go +++ b/chaincode/marbles02_private/go/marbles_chaincode_private.go @@ -523,18 +523,16 @@ func (t *SimpleChaincode) getMarblesByRange(stub shim.ChaincodeStubInterface, ar return shim.Error(err.Error()) } // Add a comma before array members, suppress it for the first array member - if bArrayMemberAlreadyWritten == true { + if bArrayMemberAlreadyWritten { 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("}") + buffer.WriteString( + fmt.Sprintf( + `{"Key":"%s", "Record":%s}`, + queryResponse.Key, queryResponse.Value, + ), + ) bArrayMemberAlreadyWritten = true } buffer.WriteString("]")