I have an object array like below
[ {"name":"heamoglobin","reading":"12"},
{"name":"mrc","reading":"3.3"},
{"name":"hct","reading":"33"} ]
I need to send this as an argument for my chaincode function. I tried stringifying the whole array like this
"[{\"name\":\"heamoglobin\",\"reading\":\"12\"},{\"name\":\"mrc\",\"reading\":\"3.3\"},{\"name\":\"hct\",\"reading\":\"33\"}]"
but didnt get a successful transaction
Any suggestions?
You must convert to string each parameter that is not already string. Something like:
await contract.submitTransaction("createReport", uid, req.body.patientID, user[0].email, clinicProfile.centerName, date.toString(), JSON.stringify(data));
And then process suitably every parameter in your chaincode's operation (unmarshal the array, etc.).