改造和 TypedInput [英] Retrofit and TypedInput

查看:24
本文介绍了改造和 TypedInput的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从文档中可以看出,TypedInputTypedOutput 类仅用于将 MIME 类型绑定到数据.当我们必须在请求中使用 TypedInput 时.??为什么我们在发出请求时需要这个映射

From the documentation, The TypedInput and TypedOutput classes exist only to bind a mime type to data. When we have to use the TypedInput in the Request. ?? Why we need this mapping while making the Request

推荐答案

如果您对所有请求都有一致的 MIME 类型,那么您就不必担心 TypedInputTypedOutput.假设您的请求有 JSON 输入和输出,您不应该考虑使用这些.但是如果你有混合的请求,比如说 字节流、JSON 和 XML,您应该提供 你自己的转换器和不同请求的映射.

If you have consistent MIME type for all requests then you shouldn't bother about the TypedInput or TypedOutput. Let's say if you have JSON in and out for your request you should not consider using these. But if you have mixed requests, let's say byte stream, JSON and XML you should provide your own Converter and mapping for different requests.

这篇关于改造和 TypedInput的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆