How to store object in a document

I am trying to create a document where the key is some string and the value is an object, but I am getting
an IllegalArgumentException when trying so.

Here is what I have:

MutableDocument document = new MutableDocument();
Map<String, Object> map = new HashMap<>();
map.put("blah", new MyObj(val1, val2, val3));
document.setData(map);//error here: "MyObj is not a valid type. You may only pass MutableDictionary, Dictionary, MutableArray, Array, Map, List, Date, String, Number, Boolean, Blob or null."

The error message is pretty clear right? You cannot pass in custom types into the document data, only JSON types. They are listed in the error message.

To add to what Jim said - you have to (de)serialize your POJOs into a type thats recognized by CBL. If you used a library like Jackson for constructing your native objects, you can use their built in (de)serialization methods.

Here is a sample app for reference