README.md in canoser-0.1.0 vs README.md in canoser-0.1.1

- old
+ new

@@ -112,11 +112,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 ``` ### Nested data structure The following is a complex example with three data structures: @@ -144,14 +144,24 @@ ### Serialization and deserialization After defining Canoser::Struct, you don't need to implement serialization and deserialization code yourself, you can directly call the default implementation of the base class. Take the AccountResource structure as an example: ```ruby -#序列化 +# serialize an object obj = AccountResource.new(authentication_key:[...],...) bytes = obj.serialize -#反序列化 + +# deserialize an object form bytes obj = AccountResource.deserialize(bytes) +``` + +### Get field value form object +For all fields defined by the "define_field" method, the value of this field of an object can be obtained via [field_name]. such as: + +```ruby +obj[:authentication_key] +#or +obj["authentication_key"] ``` ## Development