Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weex Android 处理 json 对象中属性值为 null 的异常 #1133

Closed
candyili opened this issue Sep 3, 2016 · 7 comments
Closed

Weex Android 处理 json 对象中属性值为 null 的异常 #1133

candyili opened this issue Sep 3, 2016 · 7 comments
Assignees

Comments

@candyili
Copy link

candyili commented Sep 3, 2016

贴代码:

function getData(url, callback) {
    stream.sendHttp({
        method: ‘GET’,
        url: url
    }, function (ret) {
        var retdata = JSON.parse(ret);
    });
}

retdata为json object,其中里面有一个属性 Time 的值为 null ,怎么判断这个属性值是不是为 null
用了 retdata.Time == null 一直是 false(如果是用浏览器调试的话是 true,但是上了Android之后是 false),然后打印出来 retdata.Time[object object]

@YorkShen YorkShen assigned sospartan and unassigned YorkShen Sep 8, 2016
@YorkShen
Copy link
Contributor

YorkShen commented Sep 8, 2016

@sospartan 看一下,stream的问题

@sospartan
Copy link
Contributor

@candyili 贴一下你得json数据

@candyili
Copy link
Author

candyili commented Sep 9, 2016

{"Res":'',"Ret":{"Time":null,"Date":20160909}}
其中Ret里的Time的值为null

@sospartan
Copy link
Contributor

你先打印ret,看看是什么内容.

btw: sendhttp接口将会启用,改用stream.fetch

@candyili
Copy link
Author

candyili commented Sep 9, 2016

恩,用stream.fetch发现一个新问题:
stream.fetch({
method: ‘GET’,
url: url
}, function (ret) {
// modal.alert ( "ret = " + ret +" --- " + ret.Ret );
});

在浏览器上调试,打印出是 “ret = [object Object] --- [object Object]”;
在Android上测试,打印出是“ret = [object Object] --- undefined”;
经过抓包看两者请求的返回结果都是 {"Res":'',"Ret":{"Time":null,"Date":20160909}}

@sospartan
Copy link
Contributor

fetch的数据结构与sendhttp不同,具体请看一下 http://alibaba.github.io/weex/doc/modules/stream.html,
是在data字段中,而不是在第一级结构里,h5的实现有点问题,会进行修改.

@Jinjiang
Copy link
Contributor

这个问题长时间没有讨论和反馈,如果有更多讨论仍然可以在这里继续,但这里会做close处理
谢谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants