json path extractor processor

JSON Path Extractor

Version: 17.01

Supported Since: 17.01

What is a JSON Path Extractor?

JSON Path Extractor processing element can be used to extract a given JSON path from a JSON message payload and assign the extracted value to a given scope variable of the message context.

Sample Use Case

In the following use case, the requirement is to receive a message with JSON payload from a HTTP ingress connector, extract a given JSON path from the received message payload and pass it to a custom processing element, perform some custom processing using the extracted JSON path value and finally deliver the message to backend service via HTTP egress processor.

The challenge is to extract the given JSON path and provide it to the custom processing element.

flow extract json path

In this flow a JSON Path Extractor processing elements is configured to extract the sample JSON path $.mobile-numbers[:1].type from the input JSON payload and assign the extracted value to the scope variable JSON_VALUE and pass the message context to the next processing element for custom processing.

For the following sample input JSON payload, the value iPhone 7 plus will be assigned to the scope variable JSON_PATH

 {
   "first-name": "john",
   "last-name" : "doe",
   "age"      : 26,
   "address"  : {
     "streetAddress": "1st cross street",
     "city"         : "pettah",
     "postalCode"   : "81000"
   },
   "mobile-numbers": [
     {
       "type"  : "iPhone 7 plus",
       "number": "074-234-567-890"
     },
     {
       "type"  : "land line",
       "number": "011-234-567-890"
     }
   ]
 }

Out Ports

Next

The processing element will assign the extracted JSON path value and add the specified scope variable to the message context and it will be forwarded to this out port

On Exception

The message context will be sent to this outport if any exception occurred while extracting the provided JSON path

Parameters

JSON Path

JSON path to be extracted from the JSON message payload.

Variable Name

Name of the scope variable to be assigned with the extracted JSON path value.

In this topic
In this topic
Contact Us