You can validate an object using a JSON Schema.

You can generate dynamic objects at runtime with dynamic and expanddo

What I would like to do, is generate objects at runtime from JSON Schemas, that can then be populated as necessary.

If this seems weird, the reason is the JSON Schema will define a template to be populated from another source, but the system allows you to create new templates.

Example as requested:

Parent Object

```
public class Parent
{
    public Guid Id { get; set; }
    public string Name { get; set; }
    public int IntValue { get; set; }
    public decimal DecimalValue { get; set; }
    public double DoubleValue { get; set; }
    public float FloatValue { get; set; }
    public DateTime DateTimeValue { get; set; }

    [EnumDataType(typeof(EnumData))]
    public string EnumValue { get; set; }

    public List<Child> children { get; set; }
}

public enum EnumData
{
    Alpha,
    Beta,
    Charlie
}

```

Child Object

```
public class Child
{
    public Guid ParentId { get; set; }
    public string ChildName { get; set; }
    public int ChildInt { get; set; }
}

```

Resulting JSON Schema

```
{
  "type": "object",
  "properties": {
    "Id": {
      "type": "string"
    },
    "Name": {
      "type": [
        "string",
        "null"
      ]
    },
    "IntValue": {
      "type": "integer"
    },
    "DecimalValue": {
      "type": "number"
    },
    "DoubleValue": {
      "type": "number"
    },
    "FloatValue": {
      "type": "number"
    },
    "DateTimeValue": {
      "type": "string",
      "format": "date-time"
    },
    "EnumValue": {
      "type": [
        "string",
        "null"
      ],
      "enum": [
        "Alpha",
        "Beta",
        "Charlie"
      ]
    }
  },
  "required": [
    "Id",
    "Name",
    "IntValue",
    "DecimalValue",
    "DoubleValue",
    "FloatValue",
    "DateTimeValue",
    "EnumValue"
  ]
}

```

The schema is a definition of an object. If this definitions was created by a user choosing what properties they want, they type, acceptable values etc, then a schema could be generated.

If you could then create an instance of an object from this schema, the properties could be populated.

The point is the class won't be known at coding time.

The reason for this is we have a huge generic set of data that we need to create smaller sets from, that the user defines what these sets will be from inside the application. The definition they create can be stored and used again.