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.
class Student
{
static CreateEmpty()
{
return new Student() {
FirstName: 'Mike',
LastName: 'Flynn',
Classes: new List<Class>(),
School: new School() {
Name: 'High School'
}
}
}
}
<code>
@(Student.CreateEmpty().ToJSON())
</code>
to
<code>
{
FirstName: 'Mike',
LastName: 'Flynn',
Classes: [],
School: {
Name: 'High School'
}
}
</code>
You could use JSON.NET which supports to control the JSON format and indent it: