What is JSONata; where is it used in TR7?
Short answer
JSONata is a short expression language used for querying and transforming JSON data (JSONata); e.g. the expression status = 200 and body.status = "UP" returns true when the status code of the response is 200 and the status field in the body is UP. In TR7, JSONata is used in the following places. In the health check, by selecting JSONata expression in the Content Check Mode field of the HTTP/HTTPS profile, the response of the Backend Service is verified field by field with JSONata Query; the Expression (JSONata) health check type, on the other hand, evaluates an expression on the device and time information without sending a network request. The same content check is also present in the GTM Trigger Actions HTTP/HTTPS triggers. In AGS, the JSONata Success Expression fields of the authentication providers and of MFA and the Custom User Attribute Mapping rows take a JSONata expression. The ⚡ Expression (JSONata) option is also present in the field list of the Log Filter on the WAF Event Logs screen and of the Log Filter on the Bot/DDoS Event Logs screen.
Where It Is Used in TR7
| Where | Field / label | What for |
|---|---|---|
| Load Balancer → Profiles → Health Checks (HTTP / HTTPS); GTM → Health Checks | Content Check Mode = JSONata expression → JSONata Query | Field-by-field verification on the status, headers, body and bodyRaw values of the response |
| Same screen | Check Type = Expression (JSONata) → JSONata Expression | A decision on the device information and the time without sending a network request (e.g. device.clusterId = 1) |
| GTM → Trigger Actions (HTTP / HTTPS) | Content Check Mode = JSONata expression | Checking the response of the trigger with the same expression |
| AGS → Authentication → Authentication Providers (HTTP, Web Form); Multi-Factor Authentication (MFA) | JSONata Success Expression (Web Form, MFA) | The condition under which an authentication or OTP sending response counts as successful |
| AGS → Authentication → Authentication Providers | Custom User Attribute Mapping | Mapping the values in the provider response to session attributes |
| Left Monitor Panel → WAF-Protected vServices → vService → Event Logs | Log Filter → ⚡ Expression (JSONata) | Filtering the WAF event records with an expression (Can I write advanced filters in Event Logs with AND/OR, NOT, regex and JSONata expressions?) |
| Left Monitor Panel → Bot/DDoS Protected vServices → vService → Event Logs | Log Filter → ⚡ Expression (JSONata) | Filtering the Bot/DDoS event records with an expression |
- The JSONATA button next to the JSONata fields in the health check and AGS forms opens the JSONata Workshop window; here the expression is tried out with the field list, ready-made functions and sample scenarios.
- In the health check and AGS forms, an expression with a syntax error prevents the form from being saved; the JSONata syntax error warning appears below the field.
Common Misconceptions
- "If the status code is 200, the Backend Service is healthy." The application can report an error in the body while returning status code 200; the JSONata expression mode also checks the body (Can I validate a JSON response field by field in a health check (Content Check Mode: JSONata Expression)?).
- "The Expression (JSONata) type sends a request to the Backend Service." This type does not send a network request; it evaluates only the device and time information. Since in a cluster each device evaluates the expression with its own information, the result can differ between the devices.
- "JSONata works only on JSON bodies." In the health check, an XML body is also parsed and presented in
body; a body that cannot be parsed is read as raw text withbodyRaw.
How it is done in the documentation
