title: Display formatted JSON in the view in ASP.NET MVC
body: <p>Is there a way to format JSON to be displayed in the view?  This way when I add a new property my API documentation will be updated automatically?  Extra credit would be to surround certain elements with CSS to style it.  I would also like to do this for XML.</p>
  
  <pre><code>class Student 
  {
        static CreateEmpty()
        {
             return new Student() {
                   FirstName: 'Mike',
                   LastName: 'Flynn',
                   Classes: new List&lt;Class&gt;(),
                   School: new School() {
                        Name: 'High School'
                   }
             }
        }
  }
  
  
  &lt;code&gt;
  @(Student.CreateEmpty().ToJSON())
  &lt;/code&gt;
  </code></pre>
  
  <p>to</p>
  
  <pre><code>&lt;code&gt;
  
  {
       FirstName: 'Mike',
       LastName: 'Flynn',
       Classes: [],
       School: {
            Name: 'High School'
       }
  }
  
  &lt;/code&gt;
  </code></pre>