Introduction

edit

Meziantou.Framework.HumanReadableSerializer writes any .NET object as readable, indented text, in a YAML-like format: one Name: value line per property, nested objects indented below their name, and one - item line per item of a collection. Getting started shows an example.

It is a one-way serializer: there is no deserializer. The text is made for people and for comparisons, so it is the same on every machine: numbers and dates are written with the invariant culture, and lines are separated by \n on every platform.

When to use it

  • Snapshot tests. Meziantou.Framework.SnapshotTesting and Meziantou.Framework.InlineSnapshotTesting use it to write the value under test. See Snapshot testing.
  • Logs and diagnostics, to dump an object, an exception or an HTTP response in a form that is easy to read.
  • Diffs, to compare two objects line by line.

What you can do with it

  • Serialize any object: anonymous types, records, collections, dictionaries, enums, dates, JSON and XML documents, HTTP messages, and many .NET types. See Getting started and Output format.
  • Choose, rename and order the members with attributes or options, including on types you do not own. See Members.
  • Write a type your way with a converter. See Converters.
  • Format JSON, XML, HTML and form values embedded in the object. See JSON, XML and HTML values.
  • Write HTTP requests and responses with their headers and content. See HTTP messages.

Packages and namespaces

PackageContent
Meziantou.Framework.HumanReadableSerializerThe serializer, its options and attributes, and the JSON, XML and URL-encoded form formatters
Meziantou.Framework.HumanReadableSerializer.HtmlA formatter that normalizes HTML values

The serializer, its options, the attributes and the converter base classes are in the Meziantou.Framework.HumanReadable namespace. The formatters are in Meziantou.Framework.HumanReadable.ValueFormatters, and the HTTP options in Meziantou.Framework.HumanReadable.Converters.