protected String toJSON(Object object) {
    if (object instanceof JSONSerializable) {
      return ((JSONSerializable) object).toJSONString();
    }

    JSONSerializer jsonSerializer = JSONFactoryUtil.createJSONSerializer();

    jsonSerializer.exclude("*.class");

    return jsonSerializer.serialize(object);
  }
  protected void validate(long ddmStructureId, Fields fields) throws Exception {

    JSONSerializer jsonSerializer = JSONFactoryUtil.createJSONSerializer();

    String expectedFieldsString = jsonSerializer.serializeDeep(fields);

    long classPK = create(_jsonStorageAdapter, ddmStructureId, fields);

    DDMStructure ddmStructure = DDMStructureLocalServiceUtil.getStructure(ddmStructureId);

    DDMFormValues actualDDMFormValues = _jsonStorageAdapter.getDDMFormValues(classPK);

    Fields actualFields =
        DDMFormValuesToFieldsConverterUtil.convert(ddmStructure, actualDDMFormValues);

    Assert.assertEquals(expectedFieldsString, jsonSerializer.serializeDeep(actualFields));
  }