Table of Contents

Json

Description

Extension methods for serializing and deserializing JSON on string and object, with built-in custom converters and JSON attribute support.

Features

  • object.Json(): serialize to JSON string, optional camelCase
  • string.Json<T>(): deserialize JSON string to T
  • string.JsonFind<T>(): extract and deserialize a specific property — supports path notation root/child/leaf
  • JsonEncrypt: transparently encrypts/decrypts a property during serialization
  • JsonObfuscate: transparently obfuscates/deobfuscates a property during serialization
  • JsonCompress: transparently compresses/decompresses a property during serialization

Behavior

Built-in converters handle common edge cases — tolerant parsing of string, int, long, DateTime, DateTimeOffset, Guid, Uri and Enum. Non-serializable types (Exception, Thread, Stream etc) are silently skipped. Circular references are ignored.

JsonFind<T> searches depth-first — for List<T> automatically appends s to the type name when no path is specified.

Caveats

  • JsonFind throws if a node in a specified path is not found
  • dynamic deserialization bypasses custom converters — dates and enums return as raw strings
  • JsonSerializerOptions is not a singleton — recreated per call for thread safety
Tip

Use JsonFind<T> when consuming large third-party API responses — extract only what you need without deserializing the entire payload.