Serialize

You can use the Serialize function to convert an object into a JSON-formatted string. This function is used for exchanging data, storing structured data, or passing complex objects between workflow steps.

When to use

You can use this function to:

  • Convert objects into JSON format for external APIs or web services.
  • Store object data as JSON in database fields or files.
  • Pass complex data structures between workflow steps or processes.

When not to use

You cannot use this function in performance-sensitive loops that process a large number of objects, because serialization introduces additional processing overhead.

Syntax

string Serialize(object Object);

Parameters

Parameter Type Required Description
Object object Yes The object to be serialized into JSON format. Can be any serializable object type such as Dictionary, List, custom class, or other data structures.

Return Value

The application returns a JSON-formatted string representation of the specified object if the operation is successful.

Examples

Example 1
Serialize Dictionary to JSON String.
// Create a dictionary to store object data
Dictionary<string, object> keyValuePairs = new Dictionary<string, object>();

// Add data to the dictionary
keyValuePairs.Add("Project Code", "P0001");
keyValuePairs.Add("Description", "Project Description");
keyValuePairs.Add("Customer Name", "Customer Name");
keyValuePairs.Add("Total Cost", 1234.52);

// Convert object data into JSON string using Serialize function
string jsonString = Serialize(keyValuePairs);

// Output the JSON string
MessageList(jsonString);
// Result: {"Project Code":"P0001","Description":"Project Description","Customer Name":"Customer Name","Total Cost":1234.52}