BogaNet 1.4.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Pages
Static Public Member Functions | Properties | List of all members
BogaNet.Helper.JsonHelper Class Referenceabstract

Helper for JSON operations. Extends https://www.newtonsoft.com/json. More...

Static Public Member Functions

static bool SerializeToFile (object obj, string path, JsonSerializerSettings? settings=null)
 Serialize an object to an JSON-file.
 
static async Task< bool > SerializeToFileAsync (object obj, string path, JsonSerializerSettings? settings=null)
 Serialize an object to an JSON-file asynchronously.
 
static string SerializeToString (object obj, JsonSerializerSettings? settings=null)
 Serialize an object to an JSON-string.
 
static byte[] SerializeToByteArray (object obj, JsonSerializerSettings? settings=null)
 Serialize an object to an JSON byte-array.
 
static T DeserializeFromFile< T > (string path, JsonSerializerSettings? settings=null)
 Deserialize a JSON-file to an object.
 
static async Task< T > DeserializeFromFileAsync< T > (string path, JsonSerializerSettings? settings=null)
 Deserialize a JSON-file to an object asynchronously.
 
static T DeserializeFromString< T > (string jsonAsString, JsonSerializerSettings? settings=null)
 Deserialize a JSON-string to an object.
 
static T DeserializeFromByteArray< T > (byte[] data, JsonSerializerSettings? settings=null)
 Deserialize a JSON byte-array to an object.
 

Properties

static JsonSerializerSettings FORMAT_NONE [get]
 Format for JSON as single line.
 
static JsonSerializerSettings FORMAT_INDENTED [get]
 Format for indented JSON.
 

Detailed Description

Helper for JSON operations. Extends https://www.newtonsoft.com/json.

Member Function Documentation

◆ DeserializeFromByteArray< T >()

static T BogaNet.Helper.JsonHelper.DeserializeFromByteArray< T > ( byte[] data,
JsonSerializerSettings? settings = null )
static

Deserialize a JSON byte-array to an object.

Parameters
dataJSON of the object as byte-array
settingsSerializer settings (optional)
Returns
Object
Exceptions
Exception

◆ DeserializeFromFile< T >()

static T BogaNet.Helper.JsonHelper.DeserializeFromFile< T > ( string path,
JsonSerializerSettings? settings = null )
static

Deserialize a JSON-file to an object.

Parameters
pathJSON-file of the object
settingsSerializer settings (optional)
Returns
Object
Exceptions
Exception

◆ DeserializeFromFileAsync< T >()

static async Task< T > BogaNet.Helper.JsonHelper.DeserializeFromFileAsync< T > ( string path,
JsonSerializerSettings? settings = null )
static

Deserialize a JSON-file to an object asynchronously.

Parameters
pathJSON-file of the object
settingsSerializer settings (optional)
Returns
Object
Exceptions
Exception

◆ DeserializeFromString< T >()

static T BogaNet.Helper.JsonHelper.DeserializeFromString< T > ( string jsonAsString,
JsonSerializerSettings? settings = null )
static

Deserialize a JSON-string to an object.

Parameters
jsonAsStringJSON of the object as string
settingsSerializer settings (optional)
Returns
Object
Exceptions
Exception

◆ SerializeToByteArray()

static byte[] BogaNet.Helper.JsonHelper.SerializeToByteArray ( object obj,
JsonSerializerSettings? settings = null )
static

Serialize an object to an JSON byte-array.

Parameters
objObject to serialize
settingsSerializer settings (optional)
Returns
Object as JSON byte-array
Exceptions
Exception

◆ SerializeToFile()

static bool BogaNet.Helper.JsonHelper.SerializeToFile ( object obj,
string path,
JsonSerializerSettings? settings = null )
static

Serialize an object to an JSON-file.

Parameters
objObject to serialize
pathFile name of the JSON
settingsSerializer settings (optional)
Returns
True if the operation was successful
Exceptions
Exception

◆ SerializeToFileAsync()

static async Task< bool > BogaNet.Helper.JsonHelper.SerializeToFileAsync ( object obj,
string path,
JsonSerializerSettings? settings = null )
static

Serialize an object to an JSON-file asynchronously.

Parameters
objObject to serialize
pathFile name of the JSON
settingsSerializer settings (optional)
Returns
True if the operation was successful
Exceptions
Exception

◆ SerializeToString()

static string BogaNet.Helper.JsonHelper.SerializeToString ( object obj,
JsonSerializerSettings? settings = null )
static

Serialize an object to an JSON-string.

Parameters
objObject to serialize
settingsSerializer settings (optional)
Returns
Object as JSON-string
Exceptions
Exception

Property Documentation

◆ FORMAT_INDENTED

JsonSerializerSettings BogaNet.Helper.JsonHelper.FORMAT_INDENTED
staticget

Format for indented JSON.

◆ FORMAT_NONE

JsonSerializerSettings BogaNet.Helper.JsonHelper.FORMAT_NONE
staticget

Format for JSON as single line.


The documentation for this class was generated from the following file: