Continuation of the the Previous Post.
REST data transfer will mostly will happen through JSON.
We can get the JSON as JSON object directly and parse it in the connector itself or we can get that JSON as string and map to string property, then in activity we can parse the JSON object to any desired class.
In the implementation which we implemented last time will return the response as String.
we can map that string to clipboard Property as below:
REST data transfer will mostly will happen through JSON.
We can get the JSON as JSON object directly and parse it in the connector itself or we can get that JSON as string and map to string property, then in activity we can parse the JSON object to any desired class.
In the implementation which we implemented last time will return the response as String.
we can map that string to clipboard Property as below:
After running the data page “D_LocationsV1Adminareas”, it will give the result as below.
Data page will have source of REST Connector.
"For REST we will get the JSON string, In Connector directly we can set to Clipboard property or we can assign as JSON in response tab so that it will form the clipboard structure once it receives."
"If JSON is starting as Array without the starting element, then we cannot use Directly set as JSON. we need to set to clipboard property and parse using java function and use it.
If Starting is having single page, then directly we can use JSON in the Response Tab."
Connector Rule which is created is:
"For REST we will get the JSON string, In Connector directly we can set to Clipboard property or we can assign as JSON in response tab so that it will form the clipboard structure once it receives."
"If JSON is starting as Array without the starting element, then we cannot use Directly set as JSON. we need to set to clipboard property and parse using java function and use it.
If Starting is having single page, then directly we can use JSON in the Response Tab."
Connector Rule which is created is:
in this case JSON string we are getting and we are mapping to Clipboard and
from that JSON we need to parse to get the desired result.
from that JSON we need to parse to get the desired result.
After executing the data page,
After this u can parse this JSON string to create a page
list property.
And it will form a structure below. And can be used for any
purpose.
how to convert JSON String to Clipboard structure:
Step 1: call the data page in step 1 with the corresponding parameters.
and get the Json string in Local Variable.
D_LocationsV1Adminareas[CountryCode:"IN",apikey:"QzV2D2TGt9AyQHvzKRqbMXXXXX"]
Step 2: Using java need to parse the JSON to XML structure.
try
{
myStepPage.adoptJSONObject(GetResponse);
//myStepPage.adoptJSONObject(GetResponse, "GetStateList");
}catch(InvalidStreamError e)
{
oLog.infoForced("Got Error While Parsing");
}
so that it will be easy for Other Process in Pega.
Where Reponse Output is mapped to JSON.
sample data of JSON which we will get as below:
"{"success":true,"terms":"https:\/\/currencylayer.com\/terms","privacy":"https:\/\/currencylayer.com\/privacy","historical":true,"date":"2016-10-01","timestamp":1475366399,"source":"USD","quotes":{"USDAED":3.672904,"USDAFN":65.550003,"USDALL":122.239998}}
"
how to convert JSON String to Clipboard structure:
Step 1: call the data page in step 1 with the corresponding parameters.
and get the Json string in Local Variable.
D_LocationsV1Adminareas[CountryCode:"IN",apikey:"QzV2D2TGt9AyQHvzKRqbMXXXXX"]
Step 2: Using java need to parse the JSON to XML structure.
try
{
myStepPage.adoptJSONObject(GetResponse);
//myStepPage.adoptJSONObject(GetResponse, "GetStateList");
}catch(InvalidStreamError e)
{
oLog.infoForced("Got Error While Parsing");
}
so that it will be easy for Other Process in Pega.
Where Reponse Output is mapped to JSON.
sample data of JSON which we will get as below:
"{"success":true,"terms":"https:\/\/currencylayer.com\/terms","privacy":"https:\/\/currencylayer.com\/privacy","historical":true,"date":"2016-10-01","timestamp":1475366399,"source":"USD","quotes":{"USDAED":3.672904,"USDAFN":65.550003,"USDALL":122.239998}}
"
Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing
ReplyDeletePega Course
Pega Online Training India