(Android)Strange exception when put nested array objects

51 views
Skip to first unread message

Gee Bejoe

unread,
Aug 6, 2014, 10:02:59 PM8/6/14
to mobile-c...@googlegroups.com

I met such exception when I put a class with nested array objects
e.g.
Class A{
  B b[];
}
Class B{
  C c[];
}
Class C{
  xxx
}
Error msg:
com.couchbase.lite.CouchbaseLiteException
at com.couchbase.lite.Database.putRevision(Database.java:3578)
at com.couchbase.lite.Database.putRevision(Database.java:3421)
at com.couchbase.lite.Document.putProperties(Document.java:407)
at com.couchbase.lite.Document.putProperties(Document.java:250)

line 3578 is:
if(!oldRev.isDeleted()) {
json = encodeDocumentJSON(oldRev);
if(json == null) {
// bad or missing json
throw new CouchbaseLiteException(Status.BAD_REQUEST);//3578
}

Jens Alfke

unread,
Aug 7, 2014, 8:12:34 PM8/7/14
to mobile-c...@googlegroups.com

> On Aug 6, 2014, at 7:02 PM, Gee Bejoe <bejo...@gmail.com> wrote:
>
> I met such exception when I put a class with nested array objects
> e.g.
> Class A{
> B b[];
> }

I'm not familiar with the JSON library being used in the Java implementation, but in most platforms you can't use your own classes like that, (at least not without providing extra metadata to tell the JSON library how to encode them.) You can only use existing types and classes that map directly to JSON, like arrays and strings and maps.

—Jens
Reply all
Reply to author
Forward
0 new messages