Skip to content
ConsoleMonster
Class

ValueJson

ConsoleMonster.Values

Namespace
ConsoleMonster.Values
Assembly
ConsoleMonster
Modifiers
static

JSON for display, written with the shared value rules (ValueShaper): records become objects (dictionary keys of any type as text), collections arrays, a record seen again on the way down "(cycle)", values past the depth limit "…", secure strings masked and byte arrays as their size. Text that already is JSON is re-indented.

Inheritance

  • object
  • ValueJson

Methods

public static string Serialize(object? value, int depth = 4, ShapeOptions? options = null) #

A value as indented JSON. Finite documents are written in full, without the display node/time limits; collection enumeration must terminate. Record getters retain the shared stall protection.

Parameters

value object? required
The value.
depth int = 4 optional
How many levels of records and collections to write (default 4).
options ConsoleMonster.Values.ShapeOptions? = null optional
Shape options, or null.

Returns

string The JSON text.
public static bool TryReindent(string text, out string indented) #

Re-indents a JSON object or array with two spaces per level, or returns false when the text is not valid JSON.

Parameters

text string required
The text.
indented string required
The indented JSON.

Returns

bool True when the text is JSON.