最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - How to JSONify an object in Kotlin when the object's class doesn't implement Serializable? - Stack Overfl

programmeradmin3浏览0评论

I'm working on a proxy service modeled with Smithy. I need to pass response objects from an API/SDK to a client in an HTTP response.

Ideally, I would like the response passed to be in JSON format. The API is prone to updates and given my use case, implementing my own serialization for the response is not an option.

Is there a way to JSONify objects in kotlin without serialization? The response object I am primarily interested has a lot of nested fields if it makes any difference.

Currently my solution is passing in the response object's toString() representation which is acceptable, but not ideal as the client will have to parse the response object which is represented in python's repr() output format.

EDIT: By serialization, I mean the response object's class (from the SDK) does not implement serializable interface. I cannot make changes to this class as it is not maintained by me.

发布评论

评论列表(0)

  1. 暂无评论