Skip to content

JSONFormatter

robbyxp1 edited this page Feb 13, 2024 · 7 revisions

JSONFormatter Class

Quick formatter using Fluent syntax, quick and easy way to make a JSON string

public class JSONFormatter

Inheritance System.Object 🡒 JSONFormatter

Derived
JSONFormatterStreamer


Constructors


JSONFormatter.JSONFormatter() Constructor

Constructor

public JSONFormatter();

Properties


JSONFormatter.CurrentText Property

For debugging purposes, return current text state. Use Get() to properly close and get the text

public string CurrentText { get; }
Property Value

System.String


JSONFormatter.Length Property

How big is the JSON string

public int Length { get; }
Property Value

System.Int32


Methods


JSONFormatter.Array(string) Method

Start an array, either unnamed (at start or in array) or with property name when in object

public QuickJSON.JSONFormatter Array(string name=null);
Parameters

name System.String

Returns

JSONFormatter

Exceptions

FormatterException
Thrown if adding to an array or start with a property name, or if adding to an object without a property name


JSONFormatter.Clear() Method

Clear the buffer

public void Clear();


JSONFormatter.Close(int) Method

Close the current array, object. Can close multiple levels if depth is greater than one

public QuickJSON.JSONFormatter Close(int depth=1);
Parameters

depth System.Int32

Returns

JSONFormatter


JSONFormatter.Get() Method

Close the JSON stream and return the JSON string representation

public string Get();
Returns

System.String


JSONFormatter.LF() Method

Format the JSON output with a LF at this point

public QuickJSON.JSONFormatter LF();
Returns

JSONFormatter


JSONFormatter.Object(string) Method

Start an object, either unnamed (at start or in array) or property name

public QuickJSON.JSONFormatter Object(string name=null);
Parameters

name System.String

Returns

JSONFormatter

Exceptions

FormatterException
Thrown if adding to an array or start with a property name, or if adding to an object without a property name


JSONFormatter.Prefix(bool) Method

Internal prefix function

protected virtual void Prefix(bool named);
Parameters

named System.Boolean
is named parameter


JSONFormatter.ToFluent(JToken, bool) Method

Convert a JToken to fluent code

public static string ToFluent(QuickJSON.JToken tk, bool lf=false);
Parameters

tk JToken
Token tree

lf System.Boolean
if to index the code with new lines

Returns

System.String


JSONFormatter.ToFluent(JToken, StringBuilder, bool, string) Method

Convert a JToken to fluent code

public static void ToFluent(QuickJSON.JToken tk, System.Text.StringBuilder code, bool lf=false, string propertyname=null);
Parameters

tk JToken
Token tree

code System.Text.StringBuilder
build into stringbuilder

lf System.Boolean
if to index the code with new lines

propertyname System.String
Pass the property name to this level. Null on start


JSONFormatter.V(bool) Method

Add an array element with bool value

public QuickJSON.JSONFormatter V(bool value);
Parameters

value System.Boolean

Returns

JSONFormatter

Exceptions

FormatterException
Thrown if adding to an object because of no property name or if first element added


JSONFormatter.V(double) Method

Add an array element with a double value

public QuickJSON.JSONFormatter V(double value);
Parameters

value System.Double

Returns

JSONFormatter

Exceptions

FormatterException
Thrown if adding to an object because of no property name or if first element added


JSONFormatter.V(float) Method

Add an array element with a float value

public QuickJSON.JSONFormatter V(float value);
Parameters

value System.Single

Returns

JSONFormatter

Exceptions

FormatterException
Thrown if adding to an object because of no property name or if first element added


JSONFormatter.V(int) Method

Add an array element with int value

public QuickJSON.JSONFormatter V(int value);
Parameters

value System.Int32

Returns

JSONFormatter

Exceptions

FormatterException
Thrown if adding to an object because of no property name or if first element added


JSONFormatter.V(long) Method

Add an array element with long value

public QuickJSON.JSONFormatter V(long value);
Parameters

value System.Int64

Returns

JSONFormatter

Exceptions

FormatterException
Thrown if adding to an object because of no property name or if first element added


JSONFormatter.V(string) Method

Add an array element with string data

public QuickJSON.JSONFormatter V(string data);
Parameters

data System.String

Returns

JSONFormatter

Exceptions

FormatterException
Thrown if adding to an object because of no property name or if first element added


JSONFormatter.V(string, bool) Method

Add a property called name with bool value

public QuickJSON.JSONFormatter V(string name, bool value);
Parameters

name System.String

value System.Boolean

Returns

JSONFormatter

Exceptions

FormatterException
Thrown if adding to an array or start with a property name


JSONFormatter.V(string, double) Method

Add a property called name with a double value

public QuickJSON.JSONFormatter V(string name, double value);
Parameters

name System.String

value System.Double

Returns

JSONFormatter

Exceptions

FormatterException
Thrown if adding to an array or start with a property name


JSONFormatter.V(string, float) Method

Add a property called name with a float value

public QuickJSON.JSONFormatter V(string name, float value);
Parameters

name System.String

value System.Single

Returns

JSONFormatter

Exceptions

FormatterException
Thrown if adding to an array or start with a property name


JSONFormatter.V(string, int) Method

Add a property called name with int value

public QuickJSON.JSONFormatter V(string name, int value);
Parameters

name System.String

value System.Int32

Returns

JSONFormatter

Exceptions

FormatterException
Thrown if adding to an array with a property name or if first element added


JSONFormatter.V(string, long) Method

Add a property called name with long value

public QuickJSON.JSONFormatter V(string name, long value);
Parameters

name System.String

value System.Int64

Returns

JSONFormatter

Exceptions

FormatterException
Thrown if adding to an array or start with a property name


JSONFormatter.V(string, string) Method

Add a property called name with string data

public QuickJSON.JSONFormatter V(string name, string data);
Parameters

name System.String

data System.String

Returns

JSONFormatter

Exceptions

FormatterException
Thrown if adding to an array or start with a property name


JSONFormatter.V(string, DateTime) Method

Add a property called name with a DateTime value formatted in Zulu time

public QuickJSON.JSONFormatter V(string name, System.DateTime value);
Parameters

name System.String

value System.DateTime

Returns

JSONFormatter

Exceptions

FormatterException
Thrown if adding to an array or start with a property name


JSONFormatter.V(DateTime) Method

Add an array element with a DateTime value formatted in Zulu time

public QuickJSON.JSONFormatter V(System.DateTime value);
Parameters

value System.DateTime

Returns

JSONFormatter

Exceptions

FormatterException
Thrown if adding to an object because of no property name or if first element added


Classes

Classes
JSONFormatter.FormatterException QuickJSONFormatter Error exception
Clone this wiki locally