Comments (11)
检查下实体类结构跟数据是否一致,如果还不能解决,进群反馈吧,378530627,方便沟通
from rxhttp.
实体类的数据结构是用AS插件 GsonFormat 自动生成的,所以应该不是实体结构的问题,数据主要是不能解析出来,AsString()也不行,按道理asString()是万能的解析的吧
from rxhttp.
贴下你的代码,我这边asString是可以的
` RxHttp.get("https://api.apiopen.top/getJoke?page=1&count=2&type=video")
.asString()
.as(RxLife.asOnMain(this))
.subscribe(s -> {
}, throwable -> {
});`
from rxhttp.
from rxhttp.
是的 我用你写的Demo 跑是没有问题的,但是我用我自己的就是解析错误,代码很简单 就是一个按钮 点击请求网络
RxHttp.get("https://api.apiopen.top/getJoke?page=1&count=2&type=video")
.asString()
.as(RxLife.asOnMain(this))
.subscribe(new Consumer<String>() {
@Override
public void accept(String s) throws Exception {
Tip.show(s);
}
}, new OnError() {
@Override
public void onError(ErrorInfo error) throws Exception {
error.show(error.getErrorMsg());
}
});
from rxhttp.
RxHttp.setOnConverter(s -> s); //设置数据转换器,可用于数据解密
RxHttp.setOnParamAssembly(new Function<Param, Param>() {
/**
* <p>在这里可以为所有请求添加公共参数,也可以为url统一添加前缀或者后缀
* <p>子线程执行,每次发送请求前都会被回调
*
* @param p Param
* @return 修改后的Param对象
*/
@Override
public Param apply(Param p) {
//根据不同请求添加不同参数
if (p instanceof GetRequest) {
} else if (p instanceof PostRequest) {
} else if (p instanceof PutRequest) {
} else if (p instanceof DeleteRequest) {
}
//为url 添加前缀或者后缀 并重新设置url
//p.setUrl("");
return p.add("versionName", "1.0.0")//添加公共参数
.addHeader("deviceType", "android"); //添加公共请求头
}
});
我发现加了这些就可以了 这些都是必须的?
from rxhttp.
非必须的,过滤RxHttp,看下完整日志截图。asString方法是不可能抛出data parse fail 错误的。
from rxhttp.
我debug 是 t==null 报的解析错误
from rxhttp.
RxHttp.setOnConverter(s -> s); //设置数据转换器,可用于数据解密 被我调试出来了 是这个原因 我之前return null 了这个数据转换器是干嘛用的
from rxhttp.
如果Http返回的是密文,可通过此接口解密,并将解密后的字符串返回。
from rxhttp.
恩恩,谢谢耐心解答。
from rxhttp.
Related Issues (20)
- rxLifeScope 及 Async 方法共同使用,调用async方法将导致请求结束回调不被调用 HOT 1
- The variable 'DEV_URL' must be String HOT 5
- 用Java自定义解析器,wrappers参数传入`List.class`,ksp编译后BaseRxHttp类报错 HOT 1
- JSON日志显示问题 HOT 2
- toDownloadFlow点击Cannot find declaration to go to HOT 5
- rxhttp最低支持的gradle和kotlin版本是多少 HOT 6
- java.lang.NoSuchFieldError: No field Companion of type HOT 10
- 自动刷新问题 HOT 1
- Cannot resolve symbol 'RxHttp' HOT 9
- 下载文件可能会超时,怎么解决? HOT 2
- 打印日志添加缓存信息 HOT 1
- 有时候后台会返回一些意想不到的json HOT 11
- 编译报错了 HOT 5
- 关于后端接口数据返回null,但是接口成功自定义Parser的问题 HOT 5
- RxHttp 生成在 AndroidTest 目录 HOT 3
- ksp编译,未使用任何注解,随意更改子module中的代码,运行项目,编译报错,提示找不到RxHttp类 HOT 1
- 服务器返回数据特殊处理 HOT 6
- 打印日志是有长度限制吧?请求参数过长日志打印不全,建议提供方法设置可控制 HOT 2
- 不能直接得到Response吗 HOT 3
- java.lang.NullPointerException: <get-cache>(...) must not be null 这种一般是什么问题呀,不是必现,偶尔出现就会闪退。 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rxhttp.