Skip to content

JavaScript Object Notation

Taiizor edited this page Mar 1, 2023 · 2 revisions

JsonExtension Class

The JsonExtension class provides extension methods for working with JSON data in C#.

Methods

ToXml

Converts JSON to XML. Returns a string.

Signature

public static string ToXml(string Json = MJJM.Json, string Root = MJJM.Root, bool Special = MJJM.Special, bool Array = MJJM.Array)

Parameters

  • Json (optional, default = MJJM.Json): The JSON string to convert.
  • Root (optional, default = MJJM.Root): The root element for the resulting XML.
  • Special (optional, default = MJJM.Special): Whether or not to escape special characters.
  • Array (optional, default = MJJM.Array): Whether or not to include arrays in the resulting XML.

Returns

A string representation of the converted XML data.

ToXmlAsync

Converts JSON to XML asynchronously. Returns a task of a string.

Signature

public static Task<string> ToXmlAsync(string Json = MJJM.Json, string Root = MJJM.Root, bool Special = MJJM.Special, bool Array = MJJM.Array)

Parameters

  • Json (optional, default = MJJM.Json): The JSON string to convert.
  • Root (optional, default = MJJM.Root): The root element for the resulting XML.
  • Special (optional, default = MJJM.Special): Whether or not to escape special characters.
  • Array (optional, default = MJJM.Array): Whether or not to include arrays in the resulting XML.

Returns

A task that represents the asynchronous operation. The task result contains a string representation of the converted XML data.

ToRead

Converts JSON to a human-readable format. Returns a string.

Signature

public static string ToRead(string Json = MJJM.Json, string Token = MJJM.Token, string Value = MJJM.Value, string Separator = MJJM.Seperator)

Parameters

  • Json (optional, default = MJJM.Json): The JSON string to convert.
  • Token (optional, default = MJJM.Token): The token label to use.
  • Value (optional, default = MJJM.Value): The value label to use.
  • Separator (optional, default = MJJM.Seperator): The separator to use between tokens and values.

Returns

A string representation of the converted JSON data in a human-readable format.

ToReadAsync

Converts JSON to a human-readable format asynchronously. Returns a task of a

Clone this wiki locally