Structured Data using FoxLearn.JsonLd
By Tan Lee Published on Jun 20, 2025 53
It enables easy serialization of semantic metadata in your web applications to boost SEO, enhance search engine visibility, and improve content discoverability.
You can install via the .NET CLI:
dotnet add package FoxLearn.JsonLd
Or search for FoxLearn.JsonLd in the NuGet UI inside Visual Studio.
What is Schema.org?
Schema.org provides a standardized, machine-readable format with nearly 700 defined classes to describe real-world objects and services, widely used across the web.
Where is Schema.org Used?
Websites can add Structured Data in the HTML head section to help search engines display richer, more detailed information in search results, such as enhanced metadata shown by Google.
To use structured data in HTML, a <script>
tag with the MIME type application/ld+json
is required.
<script type="application/ld+json"> { "@context": "http://schema.org", "@type": "Organization", "url": "http://www.example.com", "name": "FoxLearn", "contactPoint": { "@type": "ContactPoint", "telephone": "+1-101-235-1125", "contactType": "Customer service" } } </script>
How to use FoxLearn.JsonLd?
For example:
var organization = new Organization { Name = "National Public Radio", Url = new Uri("http://npr.org"), Sponsor = new Organization { Name = "GloboCorp", Url = new Uri("http://www.example.com/") } }; string json = JsonLdSerializer.Serialize(organization); Console.WriteLine(json);
Output:
{ "@context": "https://schema.org", "@type": "Organization", "sponsor": { "@type": "Organization", "url": "http://www.example.com/", "name": "GloboCorp" }, "url": "http://npr.org", "name": "National Public Radio" }
If you want to include ScriptTag, you can write as shown below.
string json = JsonLdSerializer.Serialize(organization, includeScriptTag: true);
Output:
<script type="application/ld+json"> { "@context": "https://schema.org", "@type": "Organization", "sponsor": { "@type": "Organization", "url": "http://www.example.com/", "name": "GloboCorp" }, "url": "http://npr.org", "name": "National Public Radio" } </script>
Here's a more complex example using SchemaRoot to generate structured data for a full web page including images, breadcrumbs, and actions.
var root = new SchemaRoot(); var page = new WebPage() { Id = "https://foxlearn.com/course/asp-net-core-tutorials/", Url = new Uri("https://foxlearn.com/course/asp-net-core-tutorials/"), Name = "ASP.NET Core Tutorials For Beginners", IsPartOf = new WebSite() { Id = "https://foxlearn.com/#website" }, PrimaryImageOfPage = new ImageObject() { Id = "https://foxlearn.com/course/asp-net-core-tutorials/#primaryimage" }, Image = new ImageObject() { Id = "https://foxlearn.com/course/asp-net-core-tutorials/#primaryimage" }, ThumbnailUrl = new Uri("https://foxlearn.com/wp-content/uploads/2025/01/ASP.NET-Core-Tutorials-1.png"), DatePublished = new Date("2025-01-12T04:04:22+00:00"), Description = "These ASP.NET Core Tutorials are designed for beginners as well as professionals developers who want to learn ASP.NET Core.", Breadcrumb = new BreadcrumbList() { Id = "https://foxlearn.com/course/asp-net-core-tutorials/#breadcrumb" }, InLanguage = "en-US", PotentialAction = new ReactAction() { Target = new Uri("https://foxlearn.com/course/asp-net-core-tutorials/") } }; root.Graph.Add(page); ImageObject image = new ImageObject() { Id = "https://foxlearn.com/course/asp-net-core-tutorials/#primaryimage", Url = new Uri("https://foxlearn.com/wp-content/uploads/2025/01/ASP.NET-Core-Tutorials-1.png"), ContentUrl = new Uri("https://foxlearn.com/wp-content/uploads/2025/01/ASP.NET-Core-Tutorials-1.png"), InLanguage = "en-US", Width = 908, Height = 203, Caption = "ASP.NET Core Tutorials For Beginners and Professionals" }; root.Graph.Add(image); BreadcrumbList breadcrumb = new BreadcrumbList() { Id = "https://foxlearn.com/course/asp-net-core-tutorials/#breadcrumb", ItemListElement = new[] { new ListItem() { Position = 1, Name = "Home", Item = new Uri("https://foxlearn.com") }, new ListItem() { Position = 2, Name = "Courses", Item = new Uri("https://foxlearn.com/courses/") }, new ListItem() { Position = 3, Name = "ASP.NET Core Tutorials For Beginners and Professionals" }, } }; root.Graph.Add(breadcrumb); WebSite webSite = new WebSite() { Id = "https://foxlearn.com/#website", Url = new Uri("https://foxlearn.com"), Name = "FoxLearn", InLanguage = "en-US", Publisher = new Person() { Id = "https://foxlearn.com/#/schema/person/072a2d877405716353aa607e372bc216" }, PotentialAction = new SearchAction() { Target = new EntryPoint() { UrlTemplate = "https://foxlearn.com/post/search/?q={search_term_string}" }, QueryInput = new PropertyValueSpecification() { ValueRequired = true, ValueName = "search_term_string" } } }; root.Graph.Add(webSite); string json = JsonLdSerializer.Serialize(root, includeScriptTag: true); Console.WriteLine(json);
Benefits of Using FoxLearn.JsonLd
Better search performance: Appear in Google's rich cards and knowledge panels.
Higher click-through rates: Enhanced listings draw more attention.
Semantic clarity: Improve how your content is interpreted by AI tools and bots.
Clean, reusable code: Avoid manual JSON construction and validation.