Knowee
Questions
Features
Study Tools

While using Hyperledger Fabric, a user wants to define an asset named "vehicle" in chain code.Which of the following code formats can he use?Type Vehicle struct {<br /> Make string ‘json:”make”’ <br /> Category string ‘json:”category”’<br /> Model string ‘json:”model”’<br /> Color string ‘json:”color”’<br /> }Type Vehicle struct {<br /> String Make :”make” <br /> String Category :”category”<br /> String Model :”model”<br /> String Color: ”color”<br /> }Type Vehicle struct {<br /> String Make ‘xml:”make”’ <br /> String Category ‘xml:”category”’<br /> String Model ‘xml:”model”’<br /> String Color ‘xml:”color”’<br /> }Type Vehicle struct {<br /> Make string: “make” <br /> Category string: “category”<br /> Model string: “model”<br /> Color string: “color”<br /> }

Question

While using Hyperledger Fabric, a user wants to define an asset named "vehicle" in chain code.Which of the following code formats can he use?Type Vehicle struct {<br /> Make string ‘json:”make”’ <br /> Category string ‘json:”category”’<br /> Model string ‘json:”model”’<br /> Color string ‘json:”color”’<br /> }Type Vehicle struct {<br /> String Make :”make” <br /> String Category :”category”<br /> String Model :”model”<br /> String Color: ”color”<br /> }Type Vehicle struct {<br /> String Make ‘xml:”make”’ <br /> String Category ‘xml:”category”’<br /> String Model ‘xml:”model”’<br /> String Color ‘xml:”color”’<br /> }Type Vehicle struct {<br /> Make string: “make” <br /> Category string: “category”<br /> Model string: “model”<br /> Color string: “color”<br /> }

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

The correct format to define an asset named "vehicle" in chain code while using Hyperledger Fabric is:

type Vehicle struct {
    Make string `json:"make"`
    Category string `json:"category"`
    Model string `json:"model"`
    Color string `json:"color"`
}

This is because Hyperledger Fabric chaincode is written in Go, and this is the correct syntax for defining a struct (similar to an object in other languages) in Go. The json:"make" part is a struct tag that specifies how the struct field should be encoded to/decoded from JSON. This is useful when the JSON field name is different from the struct field name, or if you want to include or exclude certain fields when the struct is converted to JSON.

This problem has been solved

Similar Questions

While using Hyperledger, a user can represent the assets in which of the following formats?[i] XML[ii] JSON[iii] BinaryOnly i and iiOnly i and iiiOnly ii and iiiAll i, ii, and iii

Architecture of Hyperledger Fabric

In Hyperledger Fabric, the SDKs are written in which of the following programming languages?(This question has multiple correct answers; choose all that apply)Node.jsRESTPerlC++

In Hyperledger Fabric, the SDKs are written in which of the following programming languages?(This question has multiple correct answers; choose all that apply)C++Node.jsPerlREST

Examine the components and workflow of Hyperledger fabric

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.