summary refs log tree commit diff stats
diff options
context:
space:
mode:
authormashingan <rahmat.d.ruffy@gmail.com>2018-09-29 15:48:01 +0700
committermashingan <rahmat.d.ruffy@gmail.com>2018-09-29 15:48:01 +0700
commit5624036251e833fe78eaf65ebd9a61b7f540be93 (patch)
tree44c543f1cb8e6c84c3c3cd5adbcdcce192278c8f
parentc404163bbf39d8d8311c516d6e89d531ffea151c (diff)
downloadNim-5624036251e833fe78eaf65ebd9a61b7f540be93.tar.gz
Fix #9111; error when parsing to aliased type field
-rw-r--r--lib/pure/json.nim16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/pure/json.nim b/lib/pure/json.nim
index 9279fea77..81d5702c9 100644
--- a/lib/pure/json.nim
+++ b/lib/pure/json.nim
@@ -1147,7 +1147,7 @@ proc processType(typeName: NimNode, obj: NimNode,
         `getEnumCall`
       )
   of nnkSym:
-    let name = ($typeName).normalize
+    let name = normalize($typeName.getTypeImpl())
     case name
     of "string":
       result = quote do:
@@ -1639,3 +1639,17 @@ when isMainModule:
   # bug #6438
   doAssert($ %*[] == "[]")
   doAssert($ %*{} == "{}")
+
+  # bug #9111
+  block:
+    type
+      Bar = string
+      Foo = object
+        a: int
+        b: Bar
+
+    let
+      js = """{"a": 123, "b": "abc"}""".parseJson
+      foo = js.to Foo
+
+    doAssert(foo.b == "abc")