code: private Map<String, Object> writeBean(Bean bean, Class<?> declaredType) {
          Map<String, Object> result = new LinkedHashMap<>();
          // 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) {
                      Object outputValue = null;
                      Class<?> propType = SerOptional.extractType(prop, bean.getClass());
                      if (value instanceof Bean) {
                          if (settings.getConverter().isConvertible(value.getClass())) {
                              outputValue = writeSimple(propType, value);
                          } else {
                              outputValue = writeBean((Bean) value, propType);
                          }
                      } else {
                          SerIterator itemIterator = settings.getIteratorFactory().create(value, prop, bean.getClass(), true);
                          if (itemIterator != null) {
                              outputValue = writeElements(itemIterator);
                          } else {
                              outputValue = writeSimple(propType, value);
                          }
                      }
                      result.put(prop.name(), outputValue);
                  }
              }
          }
          return result;
      }
docs: write a bean as a JSON object