private void writeBean(Bean bean, Class<?> declaredType) throws IOException {
        output.writeObjectStart();
        // property information
        for (MetaProperty<?> prop : bean.metaBean().metaPropertyIterable()) {
            if (prop.style().isSerializable() || (prop.style().isDerived() && settings.isIncludeDerived())) {
                Object value = SerOptional.extractValue(prop, bean);
                if (value != null) {
                    output.writeObjectKey(prop.name());
                    Class<?> propType = SerOptional.extractType(prop, bean.getClass());
                    if (value instanceof Bean) {
                        if (settings.getConverter().isConvertible(value.getClass())) {
                            writeSimple(propType, value);
                        } else {
                            writeBean((Bean) value, propType);
                        }
                    } else {
                        SerIterator itemIterator = settings.getIteratorFactory().create(value, prop, bean.getClass(), true);
                        if (itemIterator != null) {
                            writeElements(itemIterator);
                        } else {
                            writeSimple(propType, value);
                        }
                    }
                }
            }
        }
        output.writeObjectEnd();
    }
private void writeBean ( Bean bean , Class < ? > declaredType ) throws IOException { output . writeObjectStart ( ) ; for ( MetaProperty < ? > prop : bean . metaBean ( ) . metaPropertyIterable ( ) ) { if ( prop . style ( ) . isSerializable ( ) || ( prop . style ( ) . isDerived ( ) && settings . isIncludeDerived ( ) ) ) { Object value = SerOptional . extractValue ( prop , bean ) ; if ( value != null ) { output . writeObjectKey ( prop . name ( ) ) ; Class < ? > propType = SerOptional . extractType ( prop , bean . getClass ( ) ) ; if ( value instanceof Bean ) { if ( settings . getConverter ( ) . isConvertible ( value . getClass ( ) ) ) { writeSimple ( propType , value ) ; } else { writeBean ( ( Bean ) value , propType ) ; } } else { SerIterator itemIterator = settings . getIteratorFactory ( ) . create ( value , prop , bean . getClass ( ) , true ) ; if ( itemIterator != null ) { writeElements ( itemIterator ) ; } else { writeSimple ( propType , value ) ; } } } } } output . writeObjectEnd ( ) ; }
write a bean as a JSON object