The JSON.ToString property delivers the value of a JSON element in string format.
You can use this property, for example, in a simple rule to whitelist a particular client IP address.
In this rule, a given client IP address is compared to the client IP address you want to whitelist to see whether both addresses match.
Name Allow client IP address provided as JSON element value Criteria Action Client.IP equals String.ToIP(JSON.ToString(User-Defined.myjsonipaddress)) –> StopCycle
The client IP address that is to be whitelisted is provided as the value of the user-defined property User-Defined.myjsonipaddress.
The JSON.ToString property delivers this value in string format. The String.ToIP property converts the string back into an IP address, so it can be compared to the address that is the value of the Client.IP property at the beginning of the rule.
Before the UserDefined.myjsonipaddress property can be used in the sample rule, you must create it in JSON data format and set its value to the address that is to be whitelisted.
To set the value, you can use an event in another sample rule, as shown in the following.
Name Set value of JSON type user defined property to client IP address Criteria Action Event Always –> Continue – Set User-Defined.myjsonipaddress = JSON.FromString ("10.149.8.34")
The JSON.FromString property in the rule event converts the client IP address, which is specified as a property parameter in string format, into the value of a JSON element.