JSONPath: Difference between revisions

From Planfix
Jump to: navigation, search
No edit summary
No edit summary
Line 17: Line 17:
Planfix can parse emails in this format and add the necessary data into info blocks using the  [https://github.com/json-path/JsonPath JsonPath library].
Planfix can parse emails in this format and add the necessary data into info blocks using the  [https://github.com/json-path/JsonPath 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.
Note: If you use a function when parsing, make sure that you insert parenthesis at the end, otherwise the function will not work.
==Example==
 
An email is sent to Planfix with JSON:
https://s.pfx.so/pf/YE/H5gE8u.jpg
==Example №1==
Sending an Email with JSON Format to Planfix
*As an example, we'll use the following JSON:
<div style="background-color:#f9f9f9; border:1px solid #ddd; padding:1em;">
<div style="background-color:#f9f9f9; border:1px solid #ddd; padding:1em;">
{
{
"firstName": "John",
"firstName": "Denis",
"lastName": "Smith",
"lastName": "Evans",
"address": {
"address": {
"streetAddress": "10 Main Street, Apartment 101",
"streetAddress": "1109 SW 12th St",
"city": "Pleasantville",
"city": "Newport",
"postalCode": 10101
"postalCode": 97365
},
},
"phoneNumbers": [
"phoneNumbers": [
"812-123-1234",
"1-211-906-4147",
"916-123-4567"
]
]
}</div>
}</div>


 
*Let's say we need the following data from the JSON:
 
Let's say we need the following data from the JSON:
<div style="background-color:#f9f9f9; border:1px solid #ddd; padding:1em;">
<div style="background-color:#f9f9f9; border:1px solid #ddd; padding:1em;">
{
{
"firstName": "John",
"firstName": "Denis",
"lastName": "Smith",
"lastName": "Evans",
"address": {
"address": {
"streetAddress": "10 Main Street, Apartment 101",
"streetAddress": "1109 SW 12th St",
"city": "Pleasantville",
"city": "Newport",
"postalCode": 10101
"postalCode": 97365
},
},
"phoneNumbers": [
"phoneNumbers": [
"812-123-1234",
"1-211-906-4147"
"916-123-4567"
]
]
}</div>
}</div>
 
 
*We would configure the following rule for processing emails:
*We would configure the following rule for processing emails:


https://s.pfx.so/pf/6g/WV75EQ.png
https://s.pfx.so/pf/6g/WV75EQ.png


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


https://s.pfx.so/pf/mi/GUx1IE.png
https://s.pfx.so/pf/mi/GUx1IE.png


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

Revision as of 07:41, 26 November 2024

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:

WV75EQ.png

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

GUx1IE.png

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


vLjOz4.png



Go To