【问题标题】:Parse function suddenly returning invalid json解析函数突然返回无效的 json
【发布时间】:2016-01-06 07:08:08
【问题描述】:

从几个小时前开始,我所有的解析函数都返回了无效的 json。与云代码无关...我什至尝试将其回滚。我在 android 平台上,没有对它进行任何破坏性的更改..

例如, 我有登录功能...

Parse.Cloud.define("loginuser", function(request, response){

    var useremail = request.params.useremail;
    var userpassword = request.params.userpassword;
    var usersource = request.params.usersource;

    Parse.User.logIn(useremail, userpassword,{
        success:function(user){
            // Sets either candidate or business to be true depending on condition
            if (usersource == "candidate"){
                user.set("candidate", true);
            } else if (usersource == "business"){
                user.set("business", true);
            }
            user.save(null, {
                // login success & return
                success: function(user){
                    response.success(user);
                }, error: function(error){
                    response.error(error);
                }
            });
        },
        error:function(user, error){
            // login failure
            response.error(user, error);
        }
    });
});

没有任何改变......它突然开始抛出错误:

01-05 22:37:30.175 1052-1052/recruitr.recruitr E/Login error: com.parse.ParseRequest$ParseRequestException: bad json response
01-05 22:37:46.045 1052-1052/recruitr.recruitr E/Signup Error: com.parse.ParseRequest$ParseRequestException: bad json response

有人知道为什么吗?

编辑:

运行调试器,当错误消息出现时它会弹出这个:

this = {LoginActivity$4@4619} 
cancel = {boolean[1]@4623} 
logincredentials = {HashMap@4624}  size = 3
parseUser = null
e = {ParseRequest$ParseRequestException@4625} "com.parse.ParseRequest$ParseRequestException: bad json response"
 isPermanentFailure = false
 code = 100
 cause = {JSONException@4630} "org.json.JSONException: Value <html> of type java.lang.String cannot be converted to JSONObject"
  cause = {JSONException@4630} "org.json.JSONException: Value <html> of type java.lang.String cannot be converted to JSONObject"
  detailMessage = {String@4638} "Value <html> of type java.lang.String cannot be converted to JSONObject"
  stackState = {long[34]@4639} 
  stackTrace = {StackTraceElement[0]@4633} 
  suppressedExceptions = {Collections$EmptyList@4634}  size = 0
  shadow$_klass_ = {Class@497} "class org.json.JSONException"
  shadow$_monitor_ = -1960135782
 detailMessage = {String@4631} "bad json response"
 stackState = {long[30]@4632} 
 stackTrace = {StackTraceElement[0]@4633} 
 suppressedExceptions = {Collections$EmptyList@4634}  size = 0
 shadow$_klass_ = {Class@4592} "class com.parse.ParseRequest$ParseRequestException"
 shadow$_monitor_ = -2123277170

【问题讨论】:

  • 你能看到,使用开发者工具网络选项卡,原始 json 数据吗?
  • 不,请参阅更新...我看到错误代码 100。根据解析网站parse.com/docs/dotnet/api/html/… 100 表示连接失败...但它在我的手机上也失败了。会不会是解析有问题?但是我的其他应用程序没有问题...

标签: javascript android parse-platform parse-cloud-code


【解决方案1】:

发现问题:

Android Parse SDK 在新更新时遇到问题。 Parse 实际上根本没有在代码中初始化(键不工作/初始化不工作)

通过更改依赖来修复错误:

compile 'com.parse:parse-android:1.+'

compile 'com.parse:parse-android:1.12.0'

compile 'com.parse:parse-android:1.10.0'

到目前为止,两者似乎都完美无缺。

【讨论】:

    猜你喜欢
    • 2019-10-14
    • 1970-01-01
    • 1970-01-01
    • 2018-11-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-27
    • 2017-04-20
    相关资源
    最近更新 更多