mirror of
https://github.com/logos-storage/nim-serde.git
synced 2026-01-02 13:43:06 +00:00
* Change parseJson to JsonNode.parse Exporting `parseJson` causes symbol clashes in downstream repos that import std/json, so changing the signature completely avoid this clash. * Fix usages of parseJson, update README
16 lines
397 B
Nim
16 lines
397 B
Nim
import std/json as stdjson
|
|
|
|
import pkg/questionable/results
|
|
|
|
import ./types
|
|
|
|
{.push raises: [].}
|
|
|
|
proc parse*(_: type JsonNode, json: string): ?!JsonNode =
|
|
# Used as a replacement for `std/json.parseJson`. Will not raise Exception like in the
|
|
# standard library
|
|
try:
|
|
return stdjson.parseJson(json).catch
|
|
except Exception as e:
|
|
return failure newException(JsonParseError, e.msg, e)
|