Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个问题,在对象中已经有 Json 字符串的情况下,我无法将 Json 字符串反序列化为对象。
前任:
Class A { int a; String jsonRpresenationOfSomeObject; // other stuff }
我无法反序列化上述 A 类的对象。我得到字段“ jsonRpresenationOfSomeObject”的异常
jsonRpresenationOfSomeObject
自定义反序列化器不是我的用例的选项。我正在寻找通用的东西。还发现 Gson 库没有运气。 将不胜感激任何帮助。
对于您的上述场景,在 JSON 中序列化和反序列化没有问题。我已经尝试过,发现 JSON 能够正确反序列化您的类。我认为他们可能是您班级的访问说明符的问题。
如果您仍然遇到问题,请向我们提供示例源。