JSONPath

From Planfix
Revision as of 09:25, 26 November 2024 by Dmitri (talk | contribs) (→‎Example №2)
Jump to: navigation, search

Use the dedicated online service to debug and fix parsing errors: JSONPath Online Evaluator

You can parse incoming emails or webhooks in Planfix with JSON. Emails sent to Planfix can be parsed using JSON. JavaScript Object Notation is a format for storing and exchanging information available as human-readable text.  There are two main elements in a JSON object: the key and the value.

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 into info blocks using the JsonPath library. Note: If you use a function when parsing, make sure that you insert parenthesis at the end, otherwise the function will not work.

H5gE8u.jpg

Example №1

Sending an Email with JSON Format to Planfix

  • As an 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",

]

}

  • Let's say 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",

}

 

  • 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 from a product order in an online store. The data required for adding analytics is highlighted in red:

{

"site": "mysite.shop",
"name": "Denis Evans",
"id": "6598634",
"date": "26.04.2021 09:16:05",
"status": "In progress",
"email": "liz82@gmail.com",
"phone": "+7 921 625-30-24",
"address": "Павла Усова 23, корпус 1",
"price_total": "13146.00",
"item_order": [

{

"sku": "598623",
"name": "Скрепки, 28 мм, металлические, 100 шт., в картонной коробке",
"barcode": "596325689126",
"price": "14.60",
"quantity": 10

},
{

"sku": "589624",
"name": "Бумага офисная CLASSIC, А4, 80 г/м2, 500 л., марка С",
"barcode": "5963256858963",
"price": "250.00",
"quantity": 25

},
{

"sku": "579824",
"name": "Бумага офисная LUX, А4, 80 г/м2, 500 л., марка С",
"barcode": "5963256889634",
"price": "270.00",
"quantity": 25

}
]

}

Go To