CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
JsonHelper Class Reference

Convenience class for standardizing JSON responses, making it easier to export primitive data types to JSON format, and printing JSON responses. More...

## Public Member Functions
| __construct ()
| Object constructor. More...
| AddDatum ($Key, $Value)
| Add a datum identified by a key to export in the JSON response. More...
| AddWarning ($Message)
| Add a warning message to export in the JSON response. More...
| Error ($Message)
| Add an error message to export in the JSON response and then send the response. More...
| Success ($Message="")
| Signal that the callback was successful and optionally set a message. More...

## Detailed Description

Convenience class for standardizing JSON responses, making it easier to export primitive data types to JSON format, and printing JSON responses.

Definition at line 14 of file JsonHelper.php.

## Constructor & Destructor Documentation

JsonHelper::__construct | ( |  | ) |

Object constructor.

Definition at line 20 of file JsonHelper.php.

## Member Function Documentation

JsonHelper::AddDatum | ( |  | $Key,
|  |  | $Value
| ) |  |

Add a datum identified by a key to export in the JSON response.

Parameters

  string | $Key | Key used to identify the datum.
  mixed | $Value | Datum to export.

Definition at line 31 of file JsonHelper.php.

JsonHelper::AddWarning | ( |  | $Message | ) |

Add a warning message to export in the JSON response.

Warnings are for issues that might be problematic but won't interrupt execution.

Parameters

  string | $Message | Warning message to export.

See also
  Error()
  Success()

Definition at line 43 of file JsonHelper.php.

JsonHelper::Error | ( |  | $Message | ) |

Add an error message to export in the JSON response and then send the response.

A possible use of this method is to output and export a message about a missing parameter to a callback.

Parameters

  string | $Message | Error message to send.

See also
  Success()

Definition at line 55 of file JsonHelper.php.

JsonHelper::Success | ( |  | $Message = `""` | ) |

Signal that the callback was successful and optionally set a message.

Parameters

  string | $Message | Message to export. This parameter is optional.

See also
  Error()

Definition at line 65 of file JsonHelper.php.

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

- objects/JsonHelper.php