summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/std/jsonutils.nim6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/std/jsonutils.nim b/lib/std/jsonutils.nim
index 4c27bc9f2..59c3b0f7d 100644
--- a/lib/std/jsonutils.nim
+++ b/lib/std/jsonutils.nim
@@ -214,6 +214,10 @@ proc fromJson*[T](a: var T, b: JsonNode, opt = Joptions()) =
     for ai in mitems(a):
       fromJson(ai, b[i], opt)
       i.inc
+  elif T is set:
+    type E = typeof(for ai in a: ai)
+    for val in b.getElems:
+      incl a, jsonTo(val, E)
   elif T is seq:
     a.setLen b.len
     for i, val in b.getElems:
@@ -268,7 +272,7 @@ proc toJson*[T](a: T): JsonNode =
   elif T is ref | ptr:
     if system.`==`(a, nil): result = newJNull()
     else: result = toJson(a[])
-  elif T is array | seq:
+  elif T is array | seq | set:
     result = newJArray()
     for ai in a: result.add toJson(ai)
   elif T is pointer: result = toJson(cast[int](a))
='n117' href='#n117'>117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200