Skip to content

encoding/json: Decoder internally buffers full input #11046

Open
@kurin

Description

@kurin

When using the JSON package, if I encode a struct like

type Data struct {
    Count int
    Names []string
}

and then decode it into

type SmallData struct {
    Count int
}

it will still allocate memory for the list of names, even though it just gets thrown away. This becomes an annoyance when I have several multigigabyte JSON files like this. It would be neat if the JSON parser could identify what fields it cares about, or somehow be told what fields to ignore, and chuck them.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions