README-CN.md in canoser-0.1.0 vs README-CN.md in canoser-0.1.1
- old
+ new
@@ -105,11 +105,11 @@
```ruby
class Map1 < Canoser::Struct
define_field :addr, {}
end
class Map2 < Canoser::Struct
- define_field :addr, {[Canoser::Uint8], [Canoser::Uint8]}
+ define_field :addr, {[Canoser::Uint8] => [Canoser::Uint8]}
end
```
### 结构嵌套
下面是一个复杂的例子,包含三个数据结构:
@@ -142,6 +142,13 @@
obj = AccountResource.new(authentication_key:[...],...)
bytes = obj.serialize
#反序列化
obj = AccountResource.deserialize(bytes)
```
+### 从Struct对象中读取字段的值
+对于所有通过define_field方法定义的字段,可以通过[field_name]获取该字段的值。比如:
+
+```ruby
+obj[:authentication_key]
+```
+