我正在为我的项目使用Couchbase。这是我第一次使用Couchbase Lite for Android。我目前收到此错误。但是我通过了JSON Api的正确网址,你可以在这里找到它
http://query.yahooapis.com/v1/public/yql?q=select+*+from+yahoo.finance.historicaldata+where+symbol+%3D+%22YHOO%22+and
+startDate+%3D+%222015-11-02%22+and+endDate+%3D+%222016-11-02%22&format=json&diagnostics=true&env=store%3A%2F
%2Fdatatables.org%2Falltableswithkeys&callback=
但是在LogCat中我找到了这个JSON URL:
http://query.yahooapis.com/v1/public/yql?q=select+*+from+yahoo.finance.historicaldata+where+symbol+%3D+%22YHOO%22+and
+startDate+%3D+%222015-11-02%22+and+endDate+%3D+%222016-11-02%22&format=json&diagnostics=true&env=store%3A%2F
%2Fdatatables.org%2Falltableswithkeys&callback=/_local/a26bc8baaf06fc3d4d08c9b916d2a8508152b2fa
这是我得到的LogCat错误。
11-02 18:28:58.832 29526-29670/com.android.stockhawk W/Sync:
com.couchbase.lite.replicator.ReplicationInternal$11@4098198: error getting remote checkpoint
com.fasterxml.jackson.core.JsonParseException: Unexpected character ('/' (code 47)): maybe a (non-standard) comment? (not recognized as one since Feature 'ALLOW_COMMENTS' not enabled for parser)
at [Source: buffer(okhttp3.internal.http.Http1xStream$ChunkedSource@5064f7b).inputStream(); line: 1, column: 2]
at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1486)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:518)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:447)
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._skipComment(UTF8StreamJsonParser.java:2902)
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._skipWSOrEnd2(UTF8StreamJsonParser.java:2781)
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._skipWSOrEnd(UTF8StreamJsonParser.java:2737)
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.nextToken(UTF8StreamJsonParser.java:652)
at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:3600)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3545)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2646)
at com.couchbase.lite.replicator.RemoteRequest.executeRequest(RemoteRequest.java:275)
at com.couchbase.lite.replicator.RemoteRequest.execute(RemoteRequest.java:165)
at com.couchbase.lite.replicator.RemoteRequest.run(RemoteRequest.java:105)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
这是我的Couchbase代码
public void storeStockHistoryData(String stock_symbol){
try {
manager = new Manager(new AndroidContext(mContext.getApplicationContext()), Manager.DEFAULT_OPTIONS);
DatabaseOptions options = new DatabaseOptions();
options.setCreate(true);
database = manager.openDatabase(Constants.DATABASE_NAME, options);
com.couchbase.lite.View viewItemsByDate = database.getView("quote");
viewItemsByDate.setMap(new Mapper() {
@Override
public void map(Map<String, Object> document, Emitter emitter) {
Object createdAt = document.get("Symbol");
if (createdAt != null) {
emitter.emit(createdAt.toString(), null);
Log.d(LOG_TAG, "Fetched Data: " + createdAt.toString());
}
}
}, "1.0");
startSync(stock_symbol);
}catch (Exception e){
e.printStackTrace();
}
}
private void startSync(String stockSymbol) {
String url = Utils.getStockDataUrl(stockSymbol);
URL syncUrl;
try {
syncUrl = new URL(url);
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
Replication pullReplication = database.createPullReplication(syncUrl);
pullReplication.setContinuous(true);
Replication pushReplication = database.createPushReplication(syncUrl);
pushReplication.setContinuous(true);
pullReplication.start();
pushReplication.start();
pullReplication.addChangeListener(this);
pushReplication.addChangeListener(this);
}
请帮我弄清问题是什么,因为我的项目提交时间不足。
答案 0 :(得分:1)
您似乎尝试与您的应用程序同步Yahoo REST API。但Couchbase Lite不支持针对Yahoo REST API或其他REST API的复制。 Couchbase Lite通过SyncGateway或CouchDB(包括Cloudant)提供与Couchbase Server的复制。