PhenixID

Merge JSON

Version: 1.0.0

Category: Process

Extended Category: JSON

Action Package: Standard Actions

Description

Merge values from all session objects into one JSON array.

Supports SESSION and GLOBAL parameters.

ParameterMandatory/OptionalDescriptionExample
Source AttributeMandatoryThe session attribute containing the value to be used in the merge.source
Target AttributeMandatoryThe session attribute in the first session object to store the merged result.target
Failure AttributeOptionalThe attribute to store the fail message. Won’t store the fail message unless specifiedfailMsg
Source TypeOptionalWhat type the value in the source attribute should be treated as.
Default value: any
any

Source Types

  • any: Will accept any mix of types. First it will try to parse the value as JSON and if it fails fall back to treating it as a string
  • json: Will parse the value as an JSON value (JSON Object or JSON Array)
  • string: Will parse the value as a string (JSON String)
  • number: Will parse the value as a number (JSON number)
  • boolean: Will parse the value as a boolean (JSON boolean)

Use Cases

Example 1: Merge two JSON objects

ParameterValue
Source Attributesource
Target Attributetarget
Source Typejson

Two simplified session objects (represented as JSON):

  • {“source”:”{\”id\”: 1}”}
  • {“source”:”{\”id\”: 2}”}

The first session object will after execution the first session object will look like this:

{
  "source":"{\"id\": 1}",
  "target":"[{\"id\":1},{\"id\":2}]"
}

Example 2: Merge two strings

ParameterValue
Source Attributesource
Target Attributetarget
Source Typestring

Two simplified session objects (represented as JSON):

  • {“source”:”value 1″}
  • {“source”:”value 2″}

The first session object will after execution the first session object will look like this:

{
  "source":"value 1",
  "target":"[\"value 1\",\"value 2\"]"
}

Example 3: Merge JSON with failure

ParameterValue
Source Attributesource
Target Attributetarget
Failure Attributefail
Source Typejson

Two simplified session objects (represented as JSON):

  • {“source”:”{\”id\”: 1}”}
  • {“source”:”not json”}

The first session object will after execution the session objects will look like this:

  • {
    “source”:”{\”id\”: 1}”,
    “target”:”[{\”id\”:1}]”,
    “fail”: “Not every session object was successful”
    }
  • {
    “source”:”not json”,
    “fail”: “Could not process value in session attribute ‘source'”
    }


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