toJson
Converts a .NET object to a JSON string. Uses the Newtonsoft Json.NET serializer, which, unlike JSON.stringify, can serialize self-references.
Syntax
function toJson(object: any): string
| Parameter | Description |
|---|---|
object
|
.NET object you wish to serialize in JSON format. |
Return Value
Returns a JSON string describing the object.
Examples
In this example:
- We create an object called customer.
- We populate the FirstName, LastName, and Birthday properties.
- We serialize the object's contents in a string called message.
- We display the message on screen. For details on how to display messages, see ftos.context.response.setMessage.
customer = new Object(); customer.FirstName = "Jonathan"; customer.LastName = "Doe"; customer.Birthday = Date(2020, 01, 20); message = toJson(customer); ftos.context.response.setMessage(message);