Skip to content

message.formatJSON

Signature: message.formatJSON(indent)

Returns: void

Format the JSON with consistent indentations of indent.

Note

This method only applies to JSON-formatted messages.

Parameters

Type Name Description Default
Integer indent the number of spaces to indent for each additional level

Example

// Example: Format a JSON message with consistent indentation.

// Sample JSON message structure
message = qie.createJSONMessage(
    '{"name":"John Doe","age":30,"address":{"street":"123 Main St","city":"Metropolis","state":"NY"}}'
);

// Format JSON using 4-space indentation
var formattedJSON = message.formatJSON(4); // pretty-printed JSON string