jkeys089 / jserial Goto Github PK
View Code? Open in Web Editor NEWParse Java object serialization format using Go
License: MIT License
Parse Java object serialization format using Go
License: MIT License
@jkeys089 I really liked your implementation of the java serialization protocol, it is simple and convenient. But I need to use deserialization for a stream of bytes. The bytes of the serialized objects that I have to deserialize are part of the data in the stream. The stream itself contains data bytes before and after the bytes of the serialized object. Because Since this implementation uses a slice of bytes, I cannot extract the data bytes related to the deserialized object. As a solution, I need an io.Reader, or even better a bufio.Reader, so that I can use buffered stream features like unreadByte and Peek.
The java serialization protocol does not contain end-of-byte markers for the serialized object in the stream. It is necessary to be able to complete the deserialization procedure and ignore the "unknown type" error of the serializedObjectParser.content method
Thanks for the great library!
Currently the implementation expects to always read to the end of the stream.
Lines 356 to 365 in afb2f73
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
Can you add java.time.LocalDateTime parse logic as well as java.util.Date?
Hi,
I'm glad I found this library to experiment with.
I am using the library to try reading log4j logging event. I read the connection with bufio.NewReader
then fed to jserial.NewSerializedObjectParser(r)
While single item worked well, if I am trying to send multiple events at once, ie. having 2 log.debug("Hello");
in the file below, it would fail to parse anything other than the first document.
I tried peeking it, while I have EOF error, it clearly still have data behind the EOF.
Here is the log.
2023/03/07 10:21:27 Peeked: [4 109 97 105 110 112 119 4 0 0 39 16 112 120 121]
2023/03/07 10:21:27 Error parsing object: [] error reading uint16: EOF
2023/03/07 10:21:27 Error peeking reader: EOF
2023/03/07 10:21:27 Peeked: []
2023/03/07 10:21:27 Received unserialized content:
{"@":["AAAnEA==",null],"categoryName":"sender","class":{},"extends":{"org.apache.log4j.spi.LoggingEvent":{"@":["AAAnEA==",null],"categoryName":"sender","locationInfo":null,"mdcCopy":null,"mdcCopyLookupRequired":false,"ndc":null,"ndcLookupRequired":false,"renderedMessage":"Hello","threadName":"main","throwableInfo":null,"timeStamp":1678155687937}},"locationInfo":null,"mdcCopy":null,"mdcCopyLookupRequired":false,"ndc":null,"ndcLookupRequired":false,"renderedMessage":"Hello","threadName":"main","throwableInfo":null,"timeStamp":1678155687937}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.