Files
Nim/tests/stdlib/mjsonutilssandwich.nim
metagn 9c7f04dacb fix jsonutils with generic sandwiches, don't use strformat (#24560)
fixes #24559

The strformat macros have the problem that they don't capture symbols,
so don't use them in the generic `fromJson` proc here. Also `fromJson`
refers to `jsonTo` before it is declared which doesn't capture it, so
it's now forward declared.

(cherry picked from commit 5c71fbab30)
2025-01-15 10:19:51 +01:00

12 lines
300 B
Nim

import std/[json, jsonutils]
type
Kind* = enum kind1
Foo* = ref object
bleh: string
case kind*: Kind # Remove these lines and everything works 🤡
of kind1: discard # Remove these lines and everything works 🤡
proc unserialize*[T](s: string) =
discard jsonTo(parseJson(s), T)