Applies to all primitives, such as BatchIds, Bytes, etc.
const id = new BatchId('ab'.repeat(32))
console.log(id)
console.log({ id })
console.log(JSON.stringify({ id }))
BatchId {
bytes: Uint8Array(32) [
171, 171, 171, 171, 171, 171,
171, 171, 171, 171, 171, 171,
171, 171, 171, 171, 171, 171,
171, 171, 171, 171, 171, 171,
171, 171, 171, 171, 171, 171,
171, 171
],
length: 32
}
{
id: BatchId {
bytes: Uint8Array(32) [ … same 32 entries … ],
length: 32
}
}
SyntaxError: Unexpected token '«', "««««««««««"... is not valid JSON
abababababababababababababababababababababababababababababababab
{ id: 'abababababababababababababababababababababababababababababababab' }
{"id":"abababababababababababababababababababababababababababababababab"}
Goal
When Swarm primitives are printed to the console (
nodeor browser), they should be represented as hex strings rather than raw object dumps of hard-to-read bytesExample
Applies to all primitives, such as BatchIds, Bytes, etc.
Actual:
Expected: