You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2021/06/09 01:59:52 UTC

[GitHub] [servicecomb-java-chassis] liubao68 edited a comment on issue #1505: 怎么自定义Jackson的ObjectMapper?

liubao68 edited a comment on issue #1505:
URL: https://github.com/apache/servicecomb-java-chassis/issues/1505#issuecomment-857309693


   你说的这种场景我理解和是否支持定制ObjectMapper没关系,比如可以使用 `@JsonProperty` 来处理java 对象和json文本的映射。 
   ObjectMapper不允许定制更多的强调是标准行为, 比如对于`Date`类型,按照Open API的标准,一定是按照 ISO 标准格式编码, 定制 `Date`的序列化方式会使得同样的 swagger, 不同的开发者返回的 json 文本有差异。 
   
   update: 上面的观点是从java访问另外语言的snake case json接口的角度来说明的。 如果业务的需求是“所有的接口的swagger对外呈现都是snake case”, 由于java本身处理snake case比较麻烦,通过序列化参数保证来减少工作量,这种场景是适合定制下序列化参数的,不违背标准化行为。 
   
   定制ObjectMapper的重点是考虑请求链路上(比如网关->A->B的整个处理过程)所有存在序列化、反序列化都采用一样的设置。 不建议定制也是防止开发者疏漏。 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org