nim-serde/serde/json/parser.nim

15 lines
305 B
Nim
Raw Normal View History

import std/json as stdjson
2024-02-07 09:40:48 +11:00
import pkg/questionable/results
import ./types
2024-02-07 09:40:48 +11:00
{.push raises: [].}
proc parseJson*(json: string): ?!JsonNode =
## fix for nim raising Exception
try:
return stdjson.parseJson(json).catch
except Exception as e:
return failure newException(JsonParseError, e.msg)