When decoding a fully in-memory JSON (or potentially other different self-describing format) document, it's sometimes desirable to "explore" the contents of the document lazily without creating additional allocations. We should explore whether it's possible to provide this via an additional entry point into (New)JSONDecoder which provides a ~Escapable value tied to the lifetime of the input.
This is especially interesting because we're currently not in a place with the language that will allow us to make JSONDecodable types ~Escapable.
It's worth noting that something very close to this already exists with JSONMap in FoundationEssentials's implementation of JSONDecoder. It is, however, a somewhat "unsafe" version of this since it doesn't rely on lifetimes, and is not meant to be used outside the context of a decode() function execution.
When decoding a fully in-memory JSON (or potentially other different self-describing format) document, it's sometimes desirable to "explore" the contents of the document lazily without creating additional allocations. We should explore whether it's possible to provide this via an additional entry point into
(New)JSONDecoderwhich provides a~Escapablevalue tied to the lifetime of the input.This is especially interesting because we're currently not in a place with the language that will allow us to make
JSONDecodabletypes~Escapable.It's worth noting that something very close to this already exists with
JSONMapin FoundationEssentials's implementation ofJSONDecoder. It is, however, a somewhat "unsafe" version of this since it doesn't rely on lifetimes, and is not meant to be used outside the context of adecode()function execution.