go-ipld-prime
go-ipld-prime copied to clipboard
dag-json encoding should proactively reject maps that would be confusable with links during decode
The DAG-JSON encoding cannot differentiate between {a map with a single entry that has a key of "/
" and a string value} and {an IPLD link}.
Therefore, in order to be reasonably bijective, and to error early rather than leave users to run into data corruption which might only be detected arbitrarily far in the future, the dagjson codec should proactively error during encode if a map would be confusable with links during decode.
This may require finalizing some details of the DAG-JSON specification more completely before being unambiguously implementable. Namely: https://github.com/ipld/specs/pull/356 .