Skip to content

Commit

Permalink
[FAB-1931] QSCC GetQueryResult not valid
Browse files Browse the repository at this point in the history
JSON produced by GetQueryResult() is not valid if there
are multiple records returned.  Need to add a comma
before each JSON member (except for the first).

Change-Id: I1d7586f888674a2251fa5578b1bc00faa3a73dbc
Signed-off-by: denyeart <enyeart@us.ibm.com>
  • Loading branch information
denyeart committed Jan 29, 2017
1 parent 36bbeb6 commit b4c517b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/scc/qscc/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,16 @@ func getQueryResult(vledger ledger.PeerLedger, query []byte) (res pb.Response) {
buffer.WriteString("[")

var qresult ledger.QueryResult
bArrayMemberAlreadyWritten := false
qresult, err = ri.Next()
for r := 0; qresult != nil && err == nil && r < limit; r++ {
if qr, ok := qresult.(*ledger.QueryRecord); ok {
// Add a comma before array members, suppress it for the first array member
if bArrayMemberAlreadyWritten == true {
buffer.WriteString(",")
}
collectRecord(&buffer, qr)
bArrayMemberAlreadyWritten = true
}
qresult, err = ri.Next()
}
Expand Down

0 comments on commit b4c517b

Please sign in to comment.