code: public static XContentBuilder marshall(PoliciesBean bean) throws StorageException {
          try (XContentBuilder builder = XContentFactory.jsonBuilder()) {
              preMarshall(bean);
              builder
                  .startObject()
                      .field("organizationId", bean.getOrganizationId())
                      .field("entityId", bean.getEntityId())
                      .field("entityVersion", bean.getEntityVersion())
                      .field("type", bean.getType());
              List<PolicyBean> policies = bean.getPolicies();
              if (policies != null && !policies.isEmpty()) {
                  builder.startArray("policies");
                  for (PolicyBean policy : policies) {
                      builder.startObject()
                          .field("id", policy.getId())
                          .field("name", policy.getName())
                          .field("configuration", policy.getConfiguration())
                          .field("createdBy", policy.getCreatedBy())
                          .field("createdOn", policy.getCreatedOn().getTime())
                          .field("modifiedBy", policy.getModifiedBy())
                          .field("modifiedOn", policy.getModifiedOn().getTime())
                          .field("definitionId", policy.getDefinition().getId())
                          .field("orderIndex", policy.getOrderIndex())
                      .endObject();
                  }
                  builder.endArray();
              }
              builder.endObject();
              postMarshall(bean);
              return builder;
          } catch (IOException e) {
              throw new StorageException(e);
          }
      }
docs: Marshals the given bean into the given map.
  @param bean the bean
  @return the content builder
  @throws StorageException when a storage problem occurs while storing a bean