mirror of
https://github.com/waku-org/nwaku.git
synced 2025-01-18 10:52:26 +00:00
23 lines
496 B
Nim
23 lines
496 B
Nim
when (NimMajor, NimMinor) < (1, 4):
|
|
{.push raises: [Defect].}
|
|
else:
|
|
{.push raises: [].}
|
|
|
|
import
|
|
json
|
|
import
|
|
../../../waku/v2/protocol/waku_message,
|
|
./hexstrings
|
|
|
|
export hexstrings
|
|
|
|
## Json marshalling
|
|
|
|
proc `%`*(value: WakuMessage): JsonNode =
|
|
## This ensures that seq[byte] fields are marshalled to hex-format JStrings
|
|
## (as defined in `hexstrings.nim`) rather than the default JArray[JInt]
|
|
let jObj = newJObject()
|
|
for k, v in value.fieldPairs:
|
|
jObj[k] = %v
|
|
return jObj
|