【发布时间】:2021-02-03 02:58:17
【问题描述】:
我在使用“github.com/hyperledger/fabric-contract-api-go/contractapi”编写链代码时出错
type PaginatedQueryResult struct {
Records []asset `json:"records"`
FetchedRecordsCount int32 `json:"fetchedRecordsCount"`
Bookmark string `json:"bookmark"`
Completed bool `json:"completed"`
}
Record为nil时,报错:“asset_transfer_ledger chaincode Value did not match schema:\n 1.return.records: Invalid type. Expected: array, given: null”,然后我更新 像这样的 PaginatedQueryResult 结构:
type PaginatedQueryResult struct {
Records []asset `json:"records,omitempty" metadata:",optional" `
FetchedRecordsCount int32 `json:"fetchedRecordsCount"`
Bookmark string `json:"bookmark"`
Completed bool `json:"completed"`
}
如果Records为nil,这没关系,但是当Records不为nil时,会报错:“Additional property records is not allowed”
【问题讨论】:
标签: hyperledger-fabric hyperledger-chaincode