ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

android – Parse Server坏json响应错误代码100

2019-05-28 02:12:39  阅读:294  来源: 互联网

标签:json android parse-com jsonexception


我使用这个Parse Server Guide来创建一个解析服务器的本地实例.我下载并设置了示例并且运行完美,但是当我尝试使用android SDK时,我收到此错误

02-12 22:41:58.662    7211-7211/com.christoandrew.android.authens 

W/System.err﹕ com.parse.ParseRequest$ParseRequestException: bad json response
02-12 22:41:58.662    7211-7211/com.christoandrew.android.authens W/System.err﹕ at com.parse.ParseRequest.newTemporaryException(ParseRequest.java:290)
02-12 22:41:58.662    7211-7211/com.christoandrew.android.authens W/System.err﹕ at com.parse.ParseRESTCommand.onResponseAsync(ParseRESTCommand.java:308)
02-12 22:41:58.662    7211-7211/com.christoandrew.android.authens W/System.err﹕ at com.parse.ParseRequest$3.then(ParseRequest.java:137)
02-12 22:41:58.662    7211-7211/com.christoandrew.android.authens W/System.err﹕ at com.parse.ParseRequest$3.then(ParseRequest.java:133)
02-12 22:41:58.662    7211-7211/com.christoandrew.android.authens W/System.err﹕ at bolts.Task$15.run(Task.java:917)
02-12 22:41:58.662    7211-7211/com.christoandrew.android.authens W/System.err﹕ at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
02-12 22:41:58.662    7211-7211/com.christoandrew.android.authens W/System.err﹕ at bolts.Task.completeAfterTask(Task.java:908)
02-12 22:41:58.662    7211-7211/com.christoandrew.android.authens W/System.err﹕ at bolts.Task.continueWithTask(Task.java:715)
02-12 22:41:58.662    7211-7211/com.christoandrew.android.authens W/System.err﹕ at bolts.Task.continueWithTask(Task.java:726)
02-12 22:41:58.674    7211-7211/com.christoandrew.android.authens W/System.err﹕ at bolts.Task$13.then(Task.java:818)
02-12 22:41:58.674    7211-7211/com.christoandrew.android.authens W/System.err﹕ at bolts.Task$13.then(Task.java:806)
02-12 22:41:58.682    7211-7211/com.christoandrew.android.authens W/System.err﹕ at bolts.Task$15.run(Task.java:917)
02-12 22:41:58.682    7211-7211/com.christoandrew.android.authens W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
02-12 22:41:58.682    7211-7211/com.christoandrew.android.authens W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
02-12 22:41:58.682    7211-7211/com.christoandrew.android.authens W/System.err﹕ at java.lang.Thread.run(Thread.java:841)
02-12 22:41:58.682    7211-7211/com.christoandrew.android.authens W/System.err﹕ Caused by: org.json.JSONException: Value Cannot of type java.lang.String cannot be converted to JSONObject
02-12 22:41:58.682    7211-7211/com.christoandrew.android.authens W/System.err﹕ at org.json.JSON.typeMismatch(JSON.java:111)
02-12 22:41:58.682    7211-7211/com.christoandrew.android.authens W/System.err﹕ at org.json.JSONObject.<init>(JSONObject.java:159)
02-12 22:41:58.682    7211-7211/com.christoandrew.android.authens W/System.err﹕ at org.json.JSONObject.<init>(JSONObject.java:172)
02-12 22:41:58.682    7211-7211/com.christoandrew.android.authens W/System.err﹕ at com.parse.ParseRESTCommand.onResponseAsync(ParseRESTCommand.java:298)
02-12 22:41:58.690    7211-7211/com.christoandrew.android.authens W/System.err﹕ ... 13 more

这是我的index.js

    // Example express application adding the parse-server module to expose Parse
// compatible API routes.

var express = require('express');
var ParseServer = require('parse-server').ParseServer;

var databaseUri = process.env.DATABASE_URI || process.env.MONGOLAB_URI

if (!databaseUri) {
  console.log('DATABASE_URI not specified, falling back to localhost.');
}

var api = new ParseServer({
  databaseURI: databaseUri || 'mongodb://localhost:27017/authens',
  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  appId: process.env.APP_ID || 'UBXrCTUXuXf6fEBpbE7sHBamq4b0RdQcASFTHxo9',
  masterKey: process.env.MASTER_KEY || 'ghFiFWGtdymY3oXqWDTDBz6RyW7XdMyWzjXoJjFb', //Add your master key here. Keep it secret!
  clientKey: '4m2WpkkGCX77w3FNq3JWT74nVgRKNsgTj10Q1s4t',
  //restAPIKey: 'b7gUiB4cI7JeKLqKCWCkTZbBX4YA9S7xlQuwmUqX',
  //javascriptKey: '0qBhikhxV8ZtM95o1zTLFhhiuuLGiwDVcTxyvNdw',
 // dotNetKey: 'rc0uYDFU3Bo5U24PlBxKMBX7GpsHj8QHJLLVgsFg',
});
// Client-keys like the javascript key or the .NET key are not necessary with parse-server
// If you wish you require them, you can set them as options in the initialization above:
// javascriptKey, restAPIKey, dotNetKey, clientKey

var app = express();

// Serve the Parse API on the /parse URL prefix
var mountPath = process.env.PARSE_MOUNT || '/parse';
app.use(mountPath, api);

// Parse Server plays nicely with the rest of your web routes
app.get('/', function(req, res) {
  res.status(200).send('I dream of being a web site.');
});

var port = process.env.PORT || 1337;
app.listen(port, function() {
    console.log('parse-server-example running on port ' + port + '.');
});

这是我初始化的方式

Parse.enableLocalDatastore(this);
    Parse.initialize(new Parse.Configuration.Builder(this)
            .applicationId(getString(R.string.parse_app_id))
            .clientKey(getString(R.string.parse_client_key))
            .server("http://10.0.3.2:1337/parse")
            .build());
    Parse.setLogLevel(Parse.LOG_LEVEL_VERBOSE);

在教程中.我使用genymotion作为运行在10.0.3.2的虚拟设备.我有什么遗漏或这是一个普遍的问题.

更新

如果我使用cmd从cmd工作完美

curl -X POST -H "X-Parse-Application-Id: UBXrCTUXuXf6fEBpbE7sHBamq4b0RdQcASFTHxo9" -H "X-Parse-Client-Key: 4m2WpkkGCX77w3FNq3JWT74nVgRKNsgTj10Q1s4t" -H "Content-Type: application/json" -d @json.txt http://localhost:1337/parse/classes/GameScore

解决方法:

我找到了解决方案.
而不是这个

.server("http://10.0.3.2:1337/parse")

用这个

.server("http://10.0.3.2:1337/parse/")

标签:json,android,parse-com,jsonexception
来源: https://codeday.me/bug/20190528/1167703.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有