summary refs log tree commit diff stats
path: root/lib/std
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2021-05-11 13:49:47 -0700
committerGitHub <noreply@github.com>2021-05-11 22:49:47 +0200
commit1e080eb9b4e0759b8b3f87406cd58bb7a615902f (patch)
tree3936c97a153dbb9334d5a34fc3b621401aace103 /lib/std
parenta770c98e272109968203403009bfb617a5f2d33a (diff)
downloadNim-1e080eb9b4e0759b8b3f87406cd58bb7a615902f.tar.gz
jsonutils: handle holey enum as regular enum, via ord (#17995)
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/jsonutils.nim3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/std/jsonutils.nim b/lib/std/jsonutils.nim
index 59c3b0f7d..99f5ce9c6 100644
--- a/lib/std/jsonutils.nim
+++ b/lib/std/jsonutils.nim
@@ -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