Add a helper for specifying enums types that must be serialized as strings

This commit is contained in:
Zahary Karadjov 2020-08-02 20:14:59 +03:00
parent ec374f26ca
commit f011bea54b
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
1 changed files with 4 additions and 0 deletions

View File

@ -226,3 +226,7 @@ proc toJson*(v: auto, pretty = false, typeAnnotations = false): string =
w.writeValue v
return s.getOutput(string)
template serializesAsTextInJson*(T: type[enum]) =
template writeValue*(w: var JsonWriter, val: T) =
w.writeValue $val