Skip to content

JsonUtils.fromInputStream should expect and ignore BOM #214

@christopher-johnson

Description

@christopher-johnson

Jackson will not parse BOM and throws JsonParseException. UTF-8 JSON consuming implementations like JsonUtils.fromInputStream should expect and ignore it if a document contains it.

My specific problem is that I need to deserialize a document that uses a context that contains a UTF-16 BOM.

Propose to add:

    public static Object fromInputStream(InputStream input) throws IOException {
        // no readers from inputstreams w.o. encoding!!
        BOMInputStream bOMInputStream = new BOMInputStream(input,false, ByteOrderMark.UTF_8,
                ByteOrderMark.UTF_16BE, ByteOrderMark.UTF_16LE,
                ByteOrderMark.UTF_32BE, ByteOrderMark.UTF_32LE );
        return fromInputStream(bOMInputStream, "UTF-8");
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions