Skip to content

JSONPath

To debug JSONPath expressions, use the Jayway JsonPath Evaluator online service on the Jayway tab. Planfix uses the same JSONPath implementation, so expressions behave the same way there as in Planfix.

Incoming emails, webhooks, or responses to HTTP Requests can be parsed in Planfix using JSON. JavaScript Object Notation is a format for storing and exchanging information in human-readable form. A JSON object has two main elements: keys and values.

Example:

{"city":"New York", "country":"United States"}
  • keys — city and country;
  • values — New York and United States.

Planfix can parse emails in this format and add the necessary data to infoblocks. This is done using the Jayway JsonPath Java library. JSONPath has no single implementation, and the syntax for filters and functions differs between libraries. Therefore, an expression that works in another service (for example, jsonpath.com) may return a different result in Planfix. See the Jayway JsonPath documentation for the available functions and operators.

Note that if you use a function when parsing, you must include parentheses at the end; otherwise, the function will not work:

H5gE8u.jpg

Example №1

Sending an Email with JSON Format to Planfix

  • For this example, we'll use the following JSON:
{
  "firstName": "Denis",
  "lastName": "Evans",
  "address": {
    "streetAddress": "1109 SW 12th St",
    "city": "Newport",
    "postalCode": 97365
  },
  "phoneNumbers": [
    "1-211-906-4147",
    "1-916-123-4567"
  ]
}
  • For example, we need the following data from the JSON:
{
 "firstName": "Denis",
 "lastName": "Evans",
 "address": {
   "streetAddress": "1109 SW 12th St",
   "city": "Newport",
   "postalCode": 97365
 },
 "phoneNumbers": [
   "1-211-906-4147",
   "1-916-123-4567"
 ]
}
  • We would configure the following rule for processing emails:

BGQzWr.jpg

  • Next, we create a new customer using the template, indicate which infoblocks to set from which fields, and add the contact to the task created from the email:

dL1P6b.jpg

  • As a result, the necessary data from the email in JSON format was transferred to Planfix:

NtRliu.jpg

Example №2

Adding JSON Parameters to Planfix Data Tags

  • For this example, we'll use JSON for an online store product order. The data needed to add data tags is highlighted in red:

{

"site": "mysite.shop",
"name": "Denis Evans",
"id": "6598634",
"date": "30.11.2024 09:16:05",
"status": "In progress",
"email": "techT7@gmail.com",
"phone": "+1 211 906-4147",
"address": "1109 SW 12th St1",
"price_total": "466.45",
"item_order": [

{

"sku": "598623",
"name": "Cobalt drill bit set, 29 pcs",
"barcode": "596325689126",
"price": "29.99",
"quantity": 5

},
{

"sku": "589624",
"name": "High torque driver",
"barcode": "5963256858963",
"price": "230.00",
"quantity": 1

},
{

"sku": "579824",
"name": "Half inch ratchet 120 tooth",
"barcode": "5963256889634",
"price": "43.25",
"quantity": 2

}
]

}

  • Set up a separate rule for email tasks and parse the JSON:

4bwSgN.jpg

  • Create a new task and notify the required employee that it has been created:

KxwRR2.jpg

  • Add data tags to the created task. Note that it is important to specify the parameter Add as many lines as there are values in the infoblock so that all values are added to the data tags:

k56IP5.jpg

  • As a result, the task displays the notification and data tags:

ptZGmD.jpg

LKfSAe.jpg

Go To