json-serialization

Serialize polymorphic .NET objects with System.Text.Json and custom converters.

Updated Jan 7, 2026
One-click install
npx skills add https://github.com/erymuzuan/motorent --skill json-serialization-erymuzuan
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: json-serialization
Source: https://github.com/erymuzuan/motorent/tree/main/.copilot/skills/json-serialization
Command: npx skills add https://github.com/erymuzuan/motorent --skill json-serialization-erymuzuan

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Enable high-performance polymorphic JSON serialization for .NET objects.

Core Features & Use Cases

  • System.Text.Json-based serialization with JsonPolymorphic and JsonDerivedType attributes to support derived types.
  • Custom converters for DateOnly, TimeOnly, Decimal, and Int32 to maximize performance and minimize allocations.
  • Utf8Parser integration for fast parsing and improved throughput.
  • Native .NET support and AOT-friendly serialization.

Quick Start

Create a polymorphic object graph and serialize it with System.Text.Json using the provided converters to observe fast, low-allocation output.

Frequently Asked Questions about json-serialization

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I serialize polymorphic object hierarchies with System.Text.Json in .NET?

To serialize polymorphic object hierarchies with System.Text.Json, apply JsonPolymorphic and JsonDerivedType attributes to base types, enabling the serializer to correctly resolve and process derived classes in complex object graphs.

What's the best way to improve JSON serialization performance for Decimal and Int32 types?

Improve JSON serialization performance for Decimal and Int32 types by implementing custom converters that utilize Utf8Parser for high-speed parsing, which minimizes memory allocations and maximizes throughput during data-exchange operations.

Does System.Text.Json support DateOnly and TimeOnly custom converters for backend services?

Yes, System.Text.Json supports DateOnly and TimeOnly custom converters, allowing backend services to precisely control date and time formatting while maintaining high-performance serialization for .NET objects.

Can I use polymorphic JSON serialization in Native AOT .NET scenarios?

You can use polymorphic JSON serialization in Native AOT .NET scenarios by leveraging System.Text.Json with JsonPolymorphic attributes, which provides AOT-friendly serialization without relying on runtime reflection.

Why does my JSON serialization drop derived type properties in .NET?

JSON serialization drops derived type properties when base classes lack polymorphic configuration, requiring JsonDerivedType attributes to inform the serializer about expected subtypes and preserve their specific data.