summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--lib/pure/marshal.nim10
-rw-r--r--tests/stdlib/tmarshal.nim14
2 files changed, 22 insertions, 2 deletions
diff --git a/lib/pure/marshal.nim b/lib/pure/marshal.nim
index 452af54d5..df527853e 100644
--- a/lib/pure/marshal.nim
+++ b/lib/pure/marshal.nim
@@ -163,7 +163,10 @@ proc loadAny(p: var JsonParser, a: Any, t: var Table[BiggestInt, pointer]) =
   of akSequence:
     case p.kind
     of jsonNull:
-      setPointer(a, nil)
+      when defined(nimSeqsV2):
+        invokeNewSeq(a, 0)
+      else:
+        setPointer(a, nil)
       next(p)
     of jsonArrayStart:
       next(p)
@@ -230,7 +233,10 @@ proc loadAny(p: var JsonParser, a: Any, t: var Table[BiggestInt, pointer]) =
   of akString:
     case p.kind
     of jsonNull:
-      setPointer(a, nil)
+      when defined(nimSeqsV2):
+        setString(a, "")
+      else:
+        setPointer(a, nil)
       next(p)
     of jsonString:
       setString(a, p.str)
diff --git a/tests/stdlib/tmarshal.nim b/tests/stdlib/tmarshal.nim
index e539b1c34..6b71e3beb 100644
--- a/tests/stdlib/tmarshal.nim
+++ b/tests/stdlib/tmarshal.nim
@@ -1,3 +1,7 @@
+discard """
+  matrix: "--mm:orc; --mm:refc"
+"""
+
 import std/marshal
 
 # TODO: add static tests
@@ -136,6 +140,16 @@ block:
   let test = to[LegacyEntry](str)
   doAssert $test == """(numeric: "")"""
 
+block:
+  let str = """{"numeric": null}"""
+
+  type
+    LegacyEntry = object
+      numeric: seq[int]
+
+  var test = to[LegacyEntry](str)
+  doAssert $test == """(numeric: @[])"""
+
 # bug #16022
 block:
   let p: proc (): string = proc (): string = "hello world"