Releases: gabbhack/deser
Releases · gabbhack/deser
v0.3.2
What's Changed
- New deserWith pragma, defaultValue pragma now works for objects, new helpers module by @gabbhack in #15
- Documentation for helpers module by @gabbhack in #18
- Do don run tests on draft PR by @gabbhack in #20
- Delete {.requiresInit.} on internal types by @gabbhack in #24
- Run tests on devel by @gabbhack in #25
Full Changelog: v0.3.1...v0.3.2
v0.3.1
v0.3.0
Breaks
- Aliases, like
type Foo = Bar
, no longer supported bymakeDe\Serializable
macros. You should callmake*
macro on original type. nil
now serialized as theNone
token instead of dereference error. How to serialize theNone
token is up to each library. deser_json, for example, serializes it asnull
. You can skip serializingnil
with the skipSerializeIf pragma.
Features
- Inheritance support. Now all fields of parent objects are serialized together with the fields of child objects. Since the feature is called inheritance, the pragmas are "inherited" from parent objects.
- renamed, renameSerialize, renameDeserialize can now accept RenameCase enum. Example:
type Foo = object
firstName {.renamed(SnakeCase).}: string
- Objects with more than one
case
on the same level are now supported. An example of how Message deserialization from the Telegram Bot API might look:
type
MessageContentType = enum
Text, Audio
Message {.renameAll(SnakeCase).} = object
case contentType {.untagged.}: MessageContentType
of Text:
text: string
of Audio:
audio: Audio
case isForward {.untagged.}: bool
of true:
forwardFrom: User
of false:
discard
- New {.aliases.} pragma. Deserialize field from the given names or from its Nim name. Accepts strings and RenameCase values.
type
User = object
nickName {.aliases("username", "login", SnakeCase).}: string
- New {.skipPrivate.}, {.skipPrivateSerializing.}, {.skipPrivateDeserializing.} pragmas. Use this pragmas to skip all private fields during serialization and/or deserialization.
type
User {.skipPrivate.} = object
id*: int
name*: string
passwordHash: string
Fixes
- Pragmas that take no arguments can now be used without brackets:
{.defaultValue().}
->{.defaultValue.}
- Correct code generation for case objects having
of
with multiple conditions
type Foo = object
case kind: bool
of true, false:
discard