首页 > 解决方案 > (eosjs) 如何获取字符串类型的行

问题描述

在 A.cpp 中,有 string 类型的 starinfo 结构和 memo 属性。

struct starinfo{
        uint64_t num;
        account_name account;
        asset price;
        string memo;
}

我发布了合约,并使用推送操作写了一些价值。

这是结果。(cleos.sh 获取表 aaaa0000aaaa0000 aaaa0000aaaa0000 星信息)

{
  "rows": [{
      "num": 0,
      "account": "aaabbbcccddd",
      "price": "1.0000 EOS",
      "memo": "M"
    }
  ],
  "more": false
}

但是当我使用 eos.getTableRows 时出现以下错误。

"Unable to unpack built-in type 'string' while processing 'starinfo.memo'"

详细地,

 Error: {"code":500,"message":"Internal Service Error","error":{"code":3015013,  "name":"unpack_exception","what":"Unpack data exception","details":[{"message"  :"Unable to unpack built-in type 'string' while processing 'starinfo.memo'","f  ile":"abi_serializer.cpp","line_number":327,"method":"_binary_to_variant"},{"m  essage":"read datastream of length 58 over by -40","file":"datastream.cpp","li  ne_number":6,"method":"throw_datastream_range_error"}]}}

当我在 cleos 控制台下获取一行时,它可以工作。但是当我使用 eosjs 获取一行时,它不起作用。

标签: eos

解决方案


推荐阅读