Skip to main content
Skyhigh Security

Use Properties to Handle JSON Data

Several properties are available on Web Gateway for reading, modifying, and creating JSON data.

For example, the JSON.FromString property is used to create a JSON element from a string. The string is specified as a parameter of the property. So JSON.FromString("Miller") delivers the string "Miller" as the value of a JSON element.

A JSON object is created using the JSON.CreateObject property. This object is initially empty. To store a JSON element inside an object, you need to identify both items by giving them names.

An object is given a name by making it a user-defined property, which is always configured with a name.

For example, you can create a user-defined property under the name User-Defined.myjsonemployee and then use an event in a rule to give it the value of the JSON.CreateObject property.

Name
Create JSON object as user-defined property
Criteria     Action         Event
Always     –> Continue     – Set User-Defined.myjsonemployee = JSON.CreateObject

The empty JSON object User-Defined.myjsonemployee can be filled using the JSON.StoreByName property, which has parameters for object name, element key, and element value.

For example, the following stores an element with the key "Last name" and the value "Miller" in the object:

JSON.StoreByName(User-Defined.myjsonemployee, "Last name", JSON.FromString("Miller"))

Storing an element inside an object can also be performed in a simpler way:

  • You need not create the object before using the JSON.StoreByName property.
    Specifying the object name as a parameter of the property creates the object if it did not exist before.
  • You need not use the JSON.FromString property to obtain the element value.
    Specifying a string directly also creates this value. The same applies to the other ordinary data types that the value of a JSON element can have.

So, the following also stores an element inside an object:

JSON.StoreByName(User-Defined.myjsonemployee, "Last name", "Miller"))

  • Was this article helpful?