Schema.org 对象转换为具有强类型的 C# POCO 类,可用于 .NET。所有类都可以序列化为 JSON/JSON-LD 和 XML,通常用于表示数据。
Schema.org 对象转换为具有强类型的 C# POCO 类,可用于 .NET。所有类都可以序列化为 JSON/JSON-LD 和 XML,通常用于表示数据。
Schema.org objects turned into strongly typed C# POCO classes for use in .NET. All classes can be serialized into JSON/JSON-LD and XML, typically used to represent structured data in the head section of html page.
var website = new WebSite()
{
AlternateName = "An Alternative Name",
Name = "Your Site Name",
Url = new Uri("https://example.com")
};
var jsonLd = website.ToString();
The code above outputs the following JSON-LD:
{
"@context":"https://schema.org",
"@type":"WebSite",
"alternateName":"An Alternative Name",
"name":"Your Site Name",
"url":"https://example.com"
}
If writing the result into a `
##### Important Security Notice
When serializing the result for a website's `
Windows UWP apps let you share data using schema.org classes. Here is an example showing how to share metadata about a book.
schema.org defines classes and properties, where each property can have a single value or an array of multiple values. Additionally, properties can have multiple types e.g. an Address property could have a type of string or a type of PostalAddress which has it's own properties such as StreetAddress or PostalCode which breaks up an address into it's constituent parts.
To facilitate this Schema.NET uses some clever C# generics and implicit type conversions so that setting a single or multiple values is possible and that setting a string or PostalAddress is also possible:
…
This magic is all carried out using implicit conversion operators in the OneOrMany, Values, Values and Values types. These types are all structs for best performance too.
For more examples and actual running code samples, take a look at the unit tests in the project source code.
There are many pending types on schema.org which are not yet fully formed and ready for production. If you need to use these, you can install the Schema.NET.Pending NuGet package instead of Schema.NET. This package contains all released schema types as well as all pending types.
| Name | Operating System | Status | History |
|---|---|---|---|
| Azure Pipelines | Ubuntu | ||
| Azure Pipelines | Mac | ||
| Azure Pipelines | Windows | ||
| Azure Pipelines | Overall | ||
| GitHub Actions | Ubuntu, Mac & Windows | ||
| AppVeyor | Ubuntu, Mac & Windows |
Please view the contributing guide for more information.
System.Text.Json support, Had all types implement IEquatable GetHashCode and added extra unit tests and bug fixes.暂无开放 Issues,或尚未同步最近议题。