Please Help with this Error Message

com.couchbase.lite.CouchbaseLiteException: Bad or missing JSON

this error occurs when i try to use putProperties().

Made a HashMap Type Object and then call that putProperties Method with HashMap Object as an argument like below

Map<String, Object> documentBody = new HashMap<String, Object>();
documentBody.put(“key”, ownClass Object);

Document document = database.createDocument();
document.putProperties(documentBody);
then Error Pops up :smile:
Error seems like cannot encode to JSON type… am I right? :frowning:
I googled for hours and cannot find any clue… So please!!! Help me ~!

p.s Merry Christmas

Hi @needHelp,

What is ownClass Object?

documentBody.put("key", ownClass Object);

Couchbase Lite Android/Java uses Jackson JSON parser internally, I assume Jackson can not serialize ownClass Object to JSON string.

Happy Holidays!

Hey :smile:

understood that Jacksn can not serialize ownClass Object to JSON String, However I found interesting one :smile:

I made two own class as ClassA and ClassB.

I put them with same routine then ClassB is only making error :frowning:

Even I still did not define any ClassA for Helping class to serialize as JSON String :frowning:

Anyway, is there any possible way to serialize JSON String from Own Class Object?

Need Help :frowning:

Probably Jackson found the ClassB object first and threw an exception, without seeing the ClassA object.

Anyway, is there any possible way to serialize JSON String from Own Class Object?

Take a look at the Jackson documentation. Or you can always create a Map from the data in the object and serialize that instead. Jackson isn’t a Couchbase library, it’s just what we use for JSON conversion in Java.