From 670d446139310673bd624cc71d764a8acfac0b33 Mon Sep 17 00:00:00 2001 From: SteveKIM Date: Mon, 23 Sep 2019 11:20:00 +0900 Subject: [PATCH] [FAB-16668] fabcar chaincode modify console output Signed-off-by: SteveKIM Change-Id: I6f549c9ed6e3142b2476d1cd8674d2a6d453668f --- chaincode/fabcar/go/fabcar.go | 16 +++++++--------- chaincode/fabcar/go/go.mod | 1 + 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/chaincode/fabcar/go/fabcar.go b/chaincode/fabcar/go/fabcar.go index f1c526ae..7a7c70be 100644 --- a/chaincode/fabcar/go/fabcar.go +++ b/chaincode/fabcar/go/fabcar.go @@ -152,18 +152,16 @@ func (s *SmartContract) queryAllCars(APIstub shim.ChaincodeStubInterface) pb.Res 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("]") diff --git a/chaincode/fabcar/go/go.mod b/chaincode/fabcar/go/go.mod index 67c7c9c5..1dd1a8a7 100644 --- a/chaincode/fabcar/go/go.mod +++ b/chaincode/fabcar/go/go.mod @@ -8,5 +8,6 @@ require ( golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 // indirect golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a // indirect golang.org/x/text v0.3.2 // indirect + google.golang.org/appengine v1.4.0 // indirect google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 // indirect )