Table of Contents


Json Helper


The JsonHelper class enables you to serialize objects into JSON or parse JSON strings and convert them into objects.

Method NameArgumentsDescription
FromJson<T>(string jsonStr)jsonString of type string, Type of the object is defined via Generics "T". Converts a JSON string to an object of type "T".
ToJson(object model)Any object typeReturns a JSON string.
ToJson(object model, 

JsonSerializationSettings settings)

Any object type for model argument,
JsonSerializationSettings options for settings 
Returns a JSON string.

 

The example below demonstrates how to convert an object to a JSON string and how to parse the JSON string back to the object:

var contact = Database.Query<Contact>()
   .Where(a => a.Email == "jeanm@mycompany.com")
   .First();

// Convert to JSON string:
string jsonStr = JsonHelper.ToJson(contact);

// Parse JSON string into object:var contactObj = JsonHelper.FromJson<Contact>(jsonStr);

 

JsonSerializationSettings

PropertyTypeNotes
ValueWhenNullstringThis value is returned if the object is null.

IndentedFormatting

boolJSON string will be prettified.
IgnoreNullsboolNull properties will not be added to the final JSON string

 

Last updated on 11/15/2025

Attachments