title: What is the proper way to wrap a JSON object in another object?
body: <p>I have run into this problem before, where I create a data model that will later be serialized into a JSON string, but I want the class containing the properties to also be serialized. See the example below:</p>
  
  <p>I have my data model:</p>
  
  <pre><code>public class MyModel
  {
      [JsonProperty(PropertyName = "Prop1")]
      public string Property1 { get; set; }
  
      [JsonProperty(PropertyName = "Prop2")]
      public string Property2 { get; set; }
  }
  </code></pre>
  
  <p>Which would then serialize to:</p>
  
  <pre><code>{
      "Prop1":"Some Value",
      "Prop2":"Some Value"
  }
  </code></pre>
  
  <p>Is there a way I can make it serialize to:</p>
  
  <pre><code>{
      "MyModel":
      {
          "Prop1":"Some Value",
          "Prop2":"Some Value"
      }
  }
  </code></pre>
  
  <p>What I am currently doing which does not seem proper at all is something like this to create a wrapping object for my JSON:</p>
  
  <p><code>string object = @"{""ticket"":" + JsonConvert.SerializeObject(model) + @"}"</code></p>
  
  <p>Is there some kind of attribute I can add to my class something like:</p>
  
  <pre><code>[SerializeThisClass, ProperName="MyModel"]
  public class MyModel
  {
      [JsonProperty(PropertyName = "Prop1")]
      public string Property1 { get; set; }
  
      [JsonProperty(PropertyName = "Prop2")]
      public string Property2 { get; set; }
  }
  </code></pre>