© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
132 replies
malkav

✅ Parse .md like .json in C# class

Does anyone know how I can parse a "settings markdown" file into a C# class, like I could do with newtonsoft for JSON files?
Example:
I have this "settings.md" file
---
Title: myTitle
first_object_settings:
  title: some_title
  subtitle: some-subtitle
  button_content: my button content
second_object_header:
  title: another_title
  subtitle: another_subtitle
second_object_settings:
  url: some.url.here
  image: path/or/url/to/image
---
---
Title: myTitle
first_object_settings:
  title: some_title
  subtitle: some-subtitle
  button_content: my button content
second_object_header:
  title: another_title
  subtitle: another_subtitle
second_object_settings:
  url: some.url.here
  image: path/or/url/to/image
---

How can I parse this into a C# class like this:
public class Setting
{
  public string Title {get;set;}
  public FirstObject FirstObject {get;set;}
  public Header SecondObjectHeader {get;set;}
  public SecondObject SecondObjectContent {get;set;}
  //...
}

public class Header 
{
  public string Title {get;set;}
  public string Subtitle {get;set;}
}

public class SecondObject
{
  public string Url {get;set;}
  public string Image {get;set;}
}
public class Setting
{
  public string Title {get;set;}
  public FirstObject FirstObject {get;set;}
  public Header SecondObjectHeader {get;set;}
  public SecondObject SecondObjectContent {get;set;}
  //...
}

public class Header 
{
  public string Title {get;set;}
  public string Subtitle {get;set;}
}

public class SecondObject
{
  public string Url {get;set;}
  public string Image {get;set;}
}


(and following the same structure any number of other objects)

I'm using DecapCMS in my Blazor project, but DecapCMS creates markdown files that I want to render the content into my blazor project
The "settings" are also created in markdown, and regular content is written under the "header" from the markdown (blog example)
---
title: Blog Title
date: Creation Date
tags: Array of Tags
---
## Blog
some actual blog content written here like regular markdown
---
title: Blog Title
date: Creation Date
tags: Array of Tags
---
## Blog
some actual blog content written here like regular markdown

I'd want to parse that into a C# class too 😅 (and the regular content I can parse into HTML without issue)
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Next page

Similar Threads

Parse Rust Enum Json in C#
C#CC# / help
3y ago
how do i parse json into a class?
C#CC# / help
4y ago
JSON Parse Help
C#CC# / help
4y ago