Skip to content

Lazy, ~Escapable decoder/enumerator type (JSON) #1914

Description

@kperryua

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestnew-codableRelated to new Swift (de)serialization APIs

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions