JSONPath: Difference between revisions

From Planfix
Jump to: navigation, search
No edit summary
No edit summary
 
(13 intermediate revisions by the same user not shown)
Line 1: Line 1:
mails 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.
[[Email rules: Extracting data | 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==
==Example==
{"city":"New York", "country":"United States"}
{"city":"New York", "country":"United States"}
keys — city and country;
*keys — city and country;
values — New York and United States
*values — New York and United States
Planfix can parse emails in this format and add the relevant data to infoblocks. The JsonPath library is used to do so.
 
Planfix can parse emails in this format and add the relevant data to [[Email rules: Extracting data | infoblocks]].  
The [https://github.com/json-path/JsonPath JsonPath library] is used to do so.
 
 


==Example==
==Example==
 
An email is sent to Planfix with JSON:
<div style="background-color:#f9f9f9; border:1px solid #ddd; padding:1em;">
<div style="background-color:#f9f9f9; border:1px solid #ddd; padding:1em;">
An email is sent to Planfix with JSON:
{
{
"firstName": "John",
"firstName": "John",
Line 24: Line 26:
"916-123-4567"
"916-123-4567"
]
]
}
}</div>
</p>
 
</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;">
{
{
"firstName": "John",
"firstName": "John",
Line 41: Line 44:
"916-123-4567"
"916-123-4567"
]
]
}
}</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
 
 
 
*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
 
 
*As a result, the necessary data from the email in JSON format was transferred to Planfix:
 
 
https://s.pfx.so/pf/on/vLjOz4.png
 





Latest revision as of 06:13, 19 April 2021

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 relevant data to infoblocks. The JsonPath library is used to do so.  


Example

An email is sent to Planfix with JSON:

{ "firstName": "John", "lastName": "Smith", "address": { "streetAddress": "10 Main Street, Apartment 101", "city": "Pleasantville", "postalCode": 10101 }, "phoneNumbers": [ "812-123-1234", "916-123-4567" ]

}

 

Let's say we need the following data from the JSON:

{ "firstName": "John", "lastName": "Smith", "address": { "streetAddress": "10 Main Street, Apartment 101", "city": "Pleasantville", "postalCode": 10101 }, "phoneNumbers": [ "812-123-1234", "916-123-4567" ]

}

 

  • 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