Skip to content

LotfiAghel/NSerializer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NSerializer

a Serializer with derived class handling (Type name handling ) such as NewthonSoft serializer in C# NimSerializer

handle derived type with type name handlening

this project create json serilizer/deserilizer function at compileTime with Macro

BE CAREFULL IT'S IN VERY PRIMARY STAGE :( but i use in real project dont worry a lot

support

support Drived Class

support enums

support Generics

support seq,hashTable

dont suport case Arm Fields

type  
  GameEventHolder* = object 
    action* : GameEvent

  GameEvent = ref object of RootObj
  
  PlayerRole* =  enum
    None=0,First=1 , Second=2, 
    
  PlayerJoin* = ref object of GameEvent
    health*:int
    role*:PlayerRole

  GenericClass[T] = ref object of GameEvent
    t*:T

defineJsonFuncsEnum(PlayerRole)

implAllFuncs(GameEvent)
implAllFuncs(PlayerJoin)
implAllFuncsP(GameEventHolder)
implAllFuncs(GenericClass[GameEventHolder])

var
    b=GenericClass[GameEventHolder](t:GameEventHolder(action:PlayerJoin(health:100,role:PlayerRole.Second)))

echo b.toJson()

output:

{
    "$type":"GenericClass[GameEventHolder]",
    "t":{
        "action":{
            "$type":"PlayerJoin",
            "health":100,
            "role":2
        }
    }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages