jsonutils: handle holey enum as regular enum, via ord (#17995)
This commit is contained in:
parent
a770c98e27
commit
1e080eb9b4
3 changed files with 9 additions and 3 deletions
|
|
@ -282,6 +282,9 @@ proc toJson*[T](a: T): JsonNode =
|
|||
elif T is bool: result = %(a)
|
||||
elif T is SomeInteger: result = %a
|
||||
elif T is Ordinal: result = %(a.ord)
|
||||
elif T is enum:
|
||||
when defined(nimLegacyJsonutilsHoleyEnum): result = %a
|
||||
else: result = %(a.ord)
|
||||
elif T is cstring: (if a == nil: result = newJNull() else: result = % $a)
|
||||
else: result = %a
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue