如何从状态的合同状态表单中获取数据,而无需进行转换?

huangapple go评论79阅读模式
英文:

How to get data from Contract State form of a state, without casting?

问题

有没有一种方法可以从ContractState表单中检索状态数据,而不需要转换?我尝试了像下面这样使用反射,但它没有返回值(我猜它返回的是状态字段“status”的元数据)。

historyForId的类型是:ArrayList<Map<String, ContractState>>
val temp2 = historyForId.first().get("contractStateData")!!.javaClass.getDeclaredField("status")

英文:

Is there a way to retrieve data from ContractState form of a state data, without casting ? I was trying like this given below using reflections, but it doesnt gave values (I guess it is returning state field "status" 's metadata).

historyForId is of type : ArrayList&lt;Map&lt;String,ContractState&gt;&gt;
val temp2 = historyForId.first().get(&quot;contractStateData&quot;)!!.javaClass.getDeclaredField(&quot;status&quot;)

答案1

得分: 1

将答案添加到在 Corda 账本 Slack 上找到的内容。发现该字段的 "isAccessible" 被设置为 false。通过显式将 "isAccessible" 分配为 true,问题得以解决。

英文:

Adding the answer as found on Corda ledger slack. It was found that "isAccessible" for the field was set to false. The issue was resolved by assigning "isAccessible" to true explicitly.

huangapple
  • 本文由 发表于 2020年7月28日 20:55:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/63134643.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定