Skip to content

Commit

Permalink
[FAB-16668] fabcar chaincode modify console output
Browse files Browse the repository at this point in the history
Signed-off-by: SteveKIM <khktoto@gmail.com>
Change-Id: I6f549c9ed6e3142b2476d1cd8674d2a6d453668f
  • Loading branch information
khktoto authored and Simon Stone committed Sep 24, 2019
1 parent f2939e2 commit 670d446
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
18 changes: 8 additions & 10 deletions chaincode/fabcar/go/fabcar.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("]")
Expand Down
1 change: 1 addition & 0 deletions chaincode/fabcar/go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

0 comments on commit 670d446

Please sign in to comment.