Giter VIP home page Giter VIP logo

Comments (11)

liujingxing avatar liujingxing commented on June 12, 2024

检查下实体类结构跟数据是否一致,如果还不能解决,进群反馈吧,378530627,方便沟通

from rxhttp.

liuwen370494581 avatar liuwen370494581 commented on June 12, 2024

实体类的数据结构是用AS插件 GsonFormat 自动生成的,所以应该不是实体结构的问题,数据主要是不能解析出来,AsString()也不行,按道理asString()是万能的解析的吧

from rxhttp.

liujingxing avatar liujingxing commented on June 12, 2024

贴下你的代码,我这边asString是可以的
` RxHttp.get("https://api.apiopen.top/getJoke?page=1&count=2&type=video")
.asString()
.as(RxLife.asOnMain(this))
.subscribe(s -> {

                }, throwable -> {

                });`

from rxhttp.

liujingxing avatar liujingxing commented on June 12, 2024

image
实际解析也是可以的,估计是你代码层面的问题

from rxhttp.

liuwen370494581 avatar liuwen370494581 commented on June 12, 2024

是的 我用你写的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.

liuwen370494581 avatar liuwen370494581 commented on June 12, 2024
    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.

liujingxing avatar liujingxing commented on June 12, 2024

非必须的,过滤RxHttp,看下完整日志截图。asString方法是不可能抛出data parse fail 错误的。

image

from rxhttp.

liuwen370494581 avatar liuwen370494581 commented on June 12, 2024

我debug 是 t==null 报的解析错误

from rxhttp.

liuwen370494581 avatar liuwen370494581 commented on June 12, 2024

RxHttp.setOnConverter(s -> s); //设置数据转换器,可用于数据解密 被我调试出来了 是这个原因 我之前return null 了这个数据转换器是干嘛用的

from rxhttp.

liujingxing avatar liujingxing commented on June 12, 2024

如果Http返回的是密文,可通过此接口解密,并将解密后的字符串返回。

from rxhttp.

liuwen370494581 avatar liuwen370494581 commented on June 12, 2024

恩恩,谢谢耐心解答。

from rxhttp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.