JSONPath: Difference between revisions
Line 72: | Line 72: | ||
https://s.pfx.so/pf/xN/NtRliu.jpg | https://s.pfx.so/pf/xN/NtRliu.jpg | ||
==Example №2== | ==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: | |||
<div style="background-color:#f9f9f9; border:1px solid #ddd; padding:1em;border-radius:4px;"> | |||
{<br> | |||
<p style="padding-left:10px;"> | |||
"site": "mysite.shop",<br> | |||
"name": "Denis Evans",<br> | |||
"id": "6598634",<br> | |||
"<span style="color:red;">date</span>": "26.04.2021 09:16:05",<br> | |||
"status": "In progress",<br> | |||
"email": "liz82@gmail.com",<br> | |||
"phone": "+7 921 625-30-24",<br> | |||
"address": "Павла Усова 23, корпус 1",<br> | |||
"price_total": "13146.00",<br> | |||
"item_order": [ | |||
</p> | |||
<p style="padding-left:10px;">{</p> | |||
<p style="padding-left:20px;"> | |||
"sku": "598623",<br> | |||
"<span style="color:red;">name</span>": "Скрепки, 28 мм, металлические, 100 шт., в картонной коробке",<br> | |||
"barcode": "596325689126",<br> | |||
"<span style="color:red;">price</span>": "14.60",<br> | |||
"<span style="color:red;">quantity</span>": 10 | |||
</p> | |||
<p style="padding-left:10px;"> | |||
},<br> | |||
{ | |||
</p> | |||
<p style="padding-left:20px;"> | |||
"sku": "589624",<br> | |||
"name": "Бумага офисная CLASSIC, А4, 80 г/м2, 500 л., марка С",<br> | |||
"barcode": "5963256858963",<br> | |||
"price": "250.00",<br> | |||
"quantity": 25 | |||
</p> | |||
<p style="padding-left:10px;"> | |||
},<br> | |||
{ | |||
</p> | |||
<p style="padding-left:20px;"> | |||
"sku": "579824",<br> | |||
"name": "Бумага офисная LUX, А4, 80 г/м2, 500 л., марка С",<br> | |||
"barcode": "5963256889634",<br> | |||
"price": "270.00",<br> | |||
"quantity": 25 | |||
</p> | |||
<p style="padding-left:10px;"> | |||
}<br> | |||
]</p> | |||
}<br> | |||
</div> | |||
== Go To == | == Go To == |
Revision as of 09:25, 26 November 2024
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.
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:
- 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:
- As a result, the necessary data from the email in JSON format was transferred to Planfix:
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
}
]
}