java - Cast from Object to List<String>: CastClassException -
i'm using touchdb ektorp in android app access couchdb
the json document i'm accessing has array of categories:
categories: ['cat1', 'cat2']
in view query i'm trying access array classcastexception when trying convert result object list:
public void map(map<string, object> document, tdviewmapemitblock emitter) { object dateadded = document.get("dateadded"); object expirydate = document.get("expirydate"); boolean expired = false; if(expirydate!=null){ expired = comparedate.isitemexpired(expirydate); } list<string> test = (list<string>)document.get("categories");
the .get()
method works fine single json fields. ideas?
document declared map<string, object>
so when .get()
- return object.
there's no direct mapping (list<string>)
exception saying need cast object rather list.
you change map hold list of strings in values, stop class cast exception should review why map declared in way is.
Comments
Post a Comment