Did you know ... Search Documentation:
Predicate event_to_json/4
 pengines:event_to_json(+Event, -JSON, +Format, +VarNames) is semidet[private]
Provide additional translations for Prolog terms to output. Defines formats are:
Simple or string format: Prolog terms are sent using quoted write.
Serialize responses as HTML string. This is intended for applications that emulate the Prolog toplevel. This format carries the following data:
List if answers, where each answer is an object with
Array of objects, each describing a variable. These objects contain these fields:
  • variables: Array of strings holding variable names
  • value: HTML-ified value of the variables
  • substitutions: Array of objects for substitutions that break cycles holding:
    • var: Name of the inserted variable
    • value: HTML-ified value
Array of strings representing HTML-ified residual goals.
 pengines:event_to_json(+PrologEvent, -JSONEvent, +Format, +VarNames)[private]
If Format equals 'json-s' or 'json-html', emit a simplified JSON representation of the data, suitable for notably SWISH. This deals with Prolog answers and output messages. If a message originates from print_message/3, it gets several additional properties:
Indicate the kind of the message (error, warning, etc.)
location:_54696{ch:CharPos, file:File, line:Line}
If the message is related to a source location, indicate the file and line and, if available, the character location.
 pengines:event_to_json(+Event, -JSON, +Format, +VarNames)[private]
Implement translation of a Pengine event to json-html format. This format represents the answer as JSON, but the variable bindings are (structured) HTML strings rather than JSON objects.

CHR residual goals are not bound to the projection variables. We hacked a bypass to fetch these by returning them in a variable named _residuals, which must be bound to a term '$residuals'(List). Such a variable is removed from the projection and added to residual goals.