{title:'Bean Contexts', updated:'9.0.0'}

At the heart of the marshalling APIs is the {@link oaj.BeanContext Bean Context} API that provides a common framework for marshalling beans and POJOs across all serializers and parsers. All serializers and parsers (and their builders) extend from the bean context API classes.

One important feature of the bean context API is the ability to wrap Java beans inside maps to allow properties to be accessed through a Map layer. Although this is used internally by all the serializers and parsers, it's often useful to use this feature by itself.

Example:

| // Wrap a bean in a map and do some simple get/set calls. | BeanMap<MyBean> myBeanMap = BeanContext.DEFAULT_SESSION.toBeanMap(myBean); | myBeanMap.put("myProperty", 123); | int myProperty = myBeanMap.get("myProperty", int.class);

The bean context API provides many settings that fine-tune how POJOs should be handled during marshalling.