Skip to content

Read single object #4

@Rots

Description

@Rots

Thanks for the great library!
Currently the implementation expects to always read to the end of the stream.

jserial/deserialize.go

Lines 356 to 365 in afb2f73

// end check has next byte in stream.
func (sop *SerializedObjectParser) end() bool {
if sop.rd.Buffered() == 0 {
_, eof := sop.rd.Peek(1)
return eof != nil
}
return false
}

I have a case where the stream contains other stuff in addition to the serialised java object. And I don't have a size of the java object to be able to r = io.LimitReader(r,size) before attempting to parse.
I.e. I want to be able to do something like:

sop := jserial.NewSerializedObjectParser(r)
minimal, err := sop.ParseSingleSerializedObjectMinimal()
if err != nil {
    return err
}
r.Read(buf)

where buf would be populated with content right after the first serialised object
minimal would then be the single deserialised object, instead of a slice/jsonArray

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions