private void appendProperty(
     JSONObject item, ISchemaType type, ISchemaProperty prop, ISerializationNode childNode) {
   Node n = (Node) childNode;
   ISchemaType propType = prop.getType();
   String propName = type.getQualifiedPropertyName(prop);
   try {
     if (prop.isAttribute()) {
       propName = "@" + propName;
       if (prop.getStructureType() == StructureType.MAP) {
         IMapSchemaProperty mapProp = (IMapSchemaProperty) prop;
         Object defaultValue = DefaultValueFactory.getDefaultValue(mapProp.getValueType());
         item.put(propName + "_1", defaultValue + "_1");
         item.put(propName + "_2", defaultValue + "_2");
       } else {
         Object defaultValue = DefaultValueFactory.getDefaultValue(propType);
         item.put(propName, defaultValue);
       }
     } else if (prop.getStructureType() == StructureType.COLLECTION) {
       item.put(propName, n.array);
     } else if (propType == null || propType.isComplex()) {
       item.put(propName, n.object);
     } else {
       Object defaultValue = DefaultValueFactory.getDefaultValue(prop);
       if (item != null) item.put(propName, defaultValue);
     }
   } catch (JSONException e) {
     e.printStackTrace();
   }
 }
    public Node(ISchemaType type, ISchemaProperty prop) {

      this.structureType = prop != null ? prop.getStructureType() : type.getParentStructureType();
      if (structureType == StructureType.COLLECTION) {
        this.array = new JSONArray();
        if (type.isComplex()) {
          array.put(new JSONObject());
          array.put(new JSONObject());
        } else {
          Object defaultValue =
              prop != null
                  ? DefaultValueFactory.getDefaultValue(prop)
                  : DefaultValueFactory.getDefaultValue(type);
          array.put(defaultValue);
          array.put(defaultValue);
        }
      } else if (structureType == StructureType.MAP) {
        this.object = new JSONObject();

        ISchemaType keyType = SimpleType.STRING;
        ISchemaType valueType =
            new TypeModelImpl("Object", "java.lang.Object", null, StructureType.COMMON);
        if (prop != null && prop instanceof IMapSchemaProperty) {
          keyType = ((IMapSchemaProperty) prop).getKeyType();
          valueType = ((IMapSchemaProperty) prop).getValueType();
          if (!keyType.getClassName().equals(SimpleType.STRING.getClassName())) {
            StringBuilder bld =
                new StringBuilder("Invalid map key type. Only String is available as key type.");
            if (type != null) {
              bld.append(" Type: " + type.getClassQualifiedName());
            }
            if (prop != null) {
              bld.append(" Property: " + prop.getName());
            }
            throw new IllegalArgumentException(bld.toString());
          }
        }
        String key = DefaultValueFactory.getDefaultValue(keyType).toString();
        try {
          if (valueType.isComplex()) {
            this.object.put(key + "_1", new JSONObject());
            this.object.put(key + "_2", new JSONObject());
          } else {
            Object defaultValue = DefaultValueFactory.getDefaultValue(valueType);
            this.object.put(key + "_1", defaultValue);
            this.object.put(key + "_2", defaultValue);
          }
        } catch (JSONException e) {
          e.printStackTrace();
        }
      } else if (type.isComplex()) {
        this.object = new JSONObject();
      }
    }