mirror of
https://github.com/logos-storage/nim-serde.git
synced 2026-01-08 08:33:09 +00:00
20 lines
462 B
Nim
20 lines
462 B
Nim
import std/json as stdjson except `%`, `%*`
|
|
|
|
import pkg/questionable
|
|
import pkg/questionable/results
|
|
|
|
export stdjson except `%`, `%*`, parseJson
|
|
|
|
{.push raises: [].}
|
|
|
|
type
|
|
SerdeError* = object of CatchableError
|
|
JsonParseError* = object of SerdeError
|
|
|
|
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)
|