theweipeng opened a new pull request, #2058:
URL: https://github.com/apache/fury/pull/2058

   ## What does this PR do?
   It is hard to describe the type of a object, we should write some code like 
this:
   ```JavaScript
   Type.object("example.foo", {
       a: Type.string()
   })
   ```
    The `Type.xxx` APIs are very flexible but not easy to use.
   
   This PR add some decorations to help simplifing the type definition. Now we 
can definition object type like this:
   
   ```JavaScript
       @Decoration.object("example.foo")
       class Foo {
         @Decoration.int32
         a: number;
       }
   
       const fury = new Fury({ refTracking: true });
       const { serialize, deserialize } = fury.registerSerializer(Foo);
       const foo = new Foo();
       foo.a = 123;
       const input = serialize(foo);
       const result = deserialize(
         input
       );
   
       expect(result instanceof Foo);
       expect(result).toEqual({ a: 123 })
   
   ```
   These decorations simply wraps the `Type.object`. Therefore, if we want to 
serialize a string or other primitive types, we can still use the `Type.xxx 
functions`. It is totally compatible.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to