我需要打印序列化Java对象的内容(例如,从缓存中检索的java.io.Serializable POJO),而不需要先验地知道它的类.
更具体一点,我不需要使用经典的ObjectInputStream来实例化一个新对象,我只需要获得对象的简单的人类可读表示(最好是JSON)而不需要在类路径中加载它的类.
换句话说,我需要将byte [](原始序列化对象)转换为JSON字符串,而无需重新实现ObjectInputStream.
解决方法:
It is a full implementation of the Object Serialization Stream
Protocol, as described in the Java Object Serialization Specification,
chapter 6. It does not instantiate any classes described in the
stream; instead, it builds up an intermediate representation of the
types, instances, and values. Because of this, it can analyze streams
without access to the class code that generated them.
标签:json,java,serialization
来源: https://codeday.me/bug/20190612/1227581.html