diff options
author | Dominik Picheta <dominikpicheta@gmail.com> | 2017-04-06 21:56:20 +0200 |
---|---|---|
committer | Dominik Picheta <dominikpicheta@gmail.com> | 2017-04-06 21:56:20 +0200 |
commit | cdfcc12529d716786683c997f1f673bd423432b6 (patch) | |
tree | 129f46cd2f8011d7f35f81c60bf49e318cb6779b | |
parent | 28f3b3d3a7dd67e6f6d11da7595250e5e218ad5d (diff) | |
download | Nim-cdfcc12529d716786683c997f1f673bd423432b6.tar.gz |
Implement json.`%` for enums.
-rw-r--r-- | lib/pure/json.nim | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/pure/json.nim b/lib/pure/json.nim index c7b581a85..bacb182b4 100644 --- a/lib/pure/json.nim +++ b/lib/pure/json.nim @@ -737,6 +737,11 @@ proc `%`*(o: ref object): JsonNode = else: result = %(o[]) +proc `%`*(o: enum): JsonNode = + ## Construct a JsonNode that represents the specified enum value as a + ## string. Creates a new ``JString JsonNode``. + result = %($o) + proc toJson(x: NimNode): NimNode {.compiletime.} = case x.kind of nnkBracket: # array |