PhenixID

Read a value from a JSON

Version: 1.0.0

Category: Process

Extended Category: JSON

Action Package: Standard Actions

Description

Read a value from JSON using JSON Pointer (RFC6901).

Supports SESSION and GLOBAL parameters.

ParameterDescriptionExample
Source AttributeThe session attribute containing the JSON to read fromsource
Target AttributeThe session attribute to store the read value intarget
JSON PointerThe JSON Pointer to locate the value in the JSON stored in Source Attribute/key
Multi ValueIf the value is an array. The items will be added to the target attribute making it a multi value attribute. Default is falsefalse
Failure AttributeThe attribute to store the fail message. Won’t store the fail message unless specifiedfailMsg

Use Cases

The example will use a session object with the attribute source containing the following JSON:

{
  "firstName": "John",
  "lastName" : "Doe",
  "age"      : 26,
  "address"  : {
    "streetAddress": "Street 1",
    "city"         : "City",
    "postalCode"   : "123456"
  },
  "phoneNumbers": [
    {
      "type"  : "mobile",
      "number": "0123-4567-8888"
    },
    {
      "type"  : "home",
      "number": "0123-4567-8910"
    }
  ]
}

Example 1: Read a value

ParameterValue
Source Attributesource
Target Attributetarget
JSON Pointer/firstName

The session object will after execution have a new attribute target that contains the string John.

Example 2: Read an array as store it as a multi value

ParameterValue
Source Attributesource
Target Attributetarget
JSON Pointer/phoneNumbers
Multi Valuetrue

The session object will after execution have a new multi value attribute target that contains the values:

  • {“type”:”mobile”,”number”:”0123-4567-8888″}
  • {“type”:”home”,”number”:”0123-4567-8910″}

Example 3: Read an array an store it as JSON array

ParameterValue
Source Attributesource
Target Attributetarget
JSON Pointer/phoneNumbers
Multi Valuefalse

The session object will after execution have a new attribute target that contains the JSON [{“type”:”mobile”,”number”:”0123-4567-8888″},{“type”:”home”,”number”:”0123-4567-8910″}]

Example 4: Read an array element

ParameterValue
Source Attributesource
Target Attributetarget
JSON Pointer/phoneNumbers/1

The session object will after execution have a new attribute target that contains the JSON {“type”:”home”,”number”:”0123-4567-8910″}.

Example 5: Read a value from a array element

ParameterValue
Source Attributesource
Target Attributetarget
JSON Pointer/phoneNumbers/1/type

The session object will after execution have a new attribute target that contains the string home.


DISCLAIMER
Information provided in this document is for your information only. PhenixID makes no explicit or implied claims to the validity of this information. Any trademarks referenced in this document are the property of their respective owners.

The origin of this information may be internal or external to PhenixID. PhenixID makes all reasonable efforts to verify this information.

PhenixID - support.phenixid.se