解析函数突然返回无效的json

时间:2016-01-06 07:08:08

标签: javascript android parse-platform cloud-code

因为几个小时前我的所有解析函数都返回了无效的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

1 个答案:

答案 0 :(得分:0)

发现问题:

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'

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