Related
How can one split the below json example by different email in a for each loop? So the end result is two completely separate entities keeping there own objects and arrays.
This result comes from a sql dump but the sql connector alters the output, so I've had to parse that output in a for each loop of its own even though there is no loop it's all in one line.
[
{
"Email": "Steve#gmail.com",
"Name": "Steve Larson",
"ID": "1111",
"Date": "2022-09-12",
"Address": "10 Chicken Place",
"Town": "Gatebody",
"Postcode": "xxx 1xx",
"Data": [
{
"Ref": "34546",
"Transaction_Date": "2018-11-29",
"Amount": 27.76,
"Balance": 27.76,
"Notes": "Beep1"
},
{
"Ref": "34546v2",
"Transaction_Date": "2018-12-24",
"Amount": 27.76,
"Balance": 27.76,
"Notes": "Beep2"
}
]
},
{
"Email": "innis#gmail.com",
"Name": "Innis Blitz",
"ID": "3456",
"Date": "2022-10-12",
"Address": "33 Snake Road",
"Town": "March",
"Postcode": "cxc 3cd",
"Data": [
{
"Ref": "078776701",
"Transaction_Date": "2021-08-27",
"Amount": 984.68,
"Balance": 984.68,
"Notes": "Yes please"
},
{
"Ref": "078776701v2",
"Transaction_Date": "2021-08-27",
"Amount": 98422.6,
"Balance": 98432.6,
"Notes": "Please not now"
}
]
}
]
Would like to do a for each so it splits the above like so. The idea then for my to load the result of the for each into a template that takes arrays.
{
"Email": "Steve#gmail.com",
"Name": "Steve Larson",
"ID": "1111",
"Date": "2022-09-12",
"Address": "10 Chicken Place",
"Town": "Gatebody",
"Postcode": "xxx 1xx",
"Data": [
{
"Ref": "34546",
"Transaction_Date": "2018-11-29",
"Amount": 27.76,
"Balance": 27.76,
"Notes": "Beep1"
},
{
"Ref": "34546v2",
"Transaction_Date": "2018-12-24",
"Amount": 27.76,
"Balance": 27.76,
"Notes": "Beep2"
}
]
}
{
"Email": "innis#gmail.com",
"Name": "Innis Blitz",
"ID": "3456",
"Date": "2022-10-12",
"Address": "33 Snake Road",
"Town": "March",
"Postcode": "cxc 3cd",
"Data": [
{
"Ref": "078776701",
"Transaction_Date": "2021-08-27",
"Amount": 984.68,
"Balance": 984.68,
"Notes": "Yes please"
},
{
"Ref": "078776701v2",
"Transaction_Date": "2021-08-27",
"Amount": 98422.6,
"Balance": 98432.6,
"Notes": "Please not now"
}
]
}
I have reproduced in my environment and got expected results and I followed below process:
I have initialized your input as below:
Then i added for each control and send the output of previous step as input as inside of foreach loop, i have added send email action.
Outputs:
I have got tow jsons in two seperate emails as above.
I have been working on a COVID-19 dashboard where I want to display the daily cases and daily deaths in the line graph. I can get the data from the following api https://api.covid19api.com/total/dayone/country/United%20Kingdom but it return me the total commutative cases and total commutative deaths on the given date. The data returned is in the following structure
const data = [
{
"Country": "United Kingdom",
"CountryCode": "",
"Province": "",
"City": "",
"CityCode": "",
"Lat": "0",
"Lon": "0",
"Confirmed": 190584,
"Deaths": 28734,
"Recovered": 0,
"Active": 161850,
"Date": "2020-05-04T00:00:00Z"
},
{
"Country": "United Kingdom",
"CountryCode": "",
"Province": "",
"City": "",
"CityCode": "",
"Lat": "0",
"Lon": "0",
"Confirmed": 194990,
"Deaths": 29427,
"Recovered": 0,
"Active": 165563,
"Date": "2020-05-05T00:00:00Z"
},
{
"Country": "United Kingdom",
"CountryCode": "",
"Province": "",
"City": "",
"CityCode": "",
"Lat": "0",
"Lon": "0",
"Confirmed": 201101,
"Deaths": 30076,
"Recovered": 0,
"Active": 171025,
"Date": "2020-05-06T00:00:00Z"
}
]
Where Confirmed is the total number of cases detected on that day. To calculate the daily cases on the specific day we can subtract the confirmed from the previous confirmed of previous date. For example 2020-05-05 the number of cases confirmed on that day can be calculated by subtracting the number of cases on 20-05-04 the previous day. So the calculation would be 194990- 190584 = 4442. For the first object of the array the value stays the same since there is no previous record to subtract from as I will be fetching the day one when a case was detected in that country. Therefore the desired data would be the following
const desiredData= [
{
"Country": "United Kingdom",
"CountryCode": "",
"Province": "",
"City": "",
"CityCode": "",
"Lat": "0",
"Lon": "0",
"Confirmed": 190584,
"Deaths": 28734,
"Recovered": 0,
"Active": 161850,
"Date": "2020-05-04T00:00:00Z"
},
{
"Country": "United Kingdom",
"CountryCode": "",
"Province": "",
"City": "",
"CityCode": "",
"Lat": "0",
"Lon": "0",
"Confirmed": 4442,
"Deaths": 29427,
"Recovered": 0,
"Active": 165563,
"Date": "2020-05-05T00:00:00Z"
},
{
"Country": "United Kingdom",
"CountryCode": "",
"Province": "",
"City": "",
"CityCode": "",
"Lat": "0",
"Lon": "0",
"Confirmed": 6111,
"Deaths": 30076,
"Recovered": 0,
"Active": 171025,
"Date": "2020-05-06T00:00:00Z"
}
]
I am using Vue.js I think this could be a basic javascript function which can loop through the array and subtract the "Confirmed" of current object from the "Confirmed" of previous object. Please do let me know how this can be acheived. Many Thanks
You can use something like this:
result = data.map((record, index, allRecords) => {
const previous = allRecords[index - 1] || {
Confirmed: 0
}
return {
...record,
newConfirmed: record.Confirmed - previous.Confirmed
}
});
Which will give you a result such as this which includes the "newConfirmed" key and value:
[{
"Country": "United Kingdom",
"CountryCode": "",
"Province": "",
"City": "",
"CityCode": "",
"Lat": "0",
"Lon": "0",
"Confirmed": 190584,
"Deaths": 28734,
"Recovered": 0,
"Active": 161850,
"Date": "2020-05-04T00:00:00Z",
"newConfirmed": 190584
}, {
"Country": "United Kingdom",
"CountryCode": "",
"Province": "",
"City": "",
"CityCode": "",
"Lat": "0",
"Lon": "0",
"Confirmed": 194990,
"Deaths": 29427,
"Recovered": 0,
"Active": 165563,
"Date": "2020-05-05T00:00:00Z",
"newConfirmed": 4406
}, {
"Country": "United Kingdom",
"CountryCode": "",
"Province": "",
"City": "",
"CityCode": "",
"Lat": "0",
"Lon": "0",
"Confirmed": 201101,
"Deaths": 30076,
"Recovered": 0,
"Active": 171025,
"Date": "2020-05-06T00:00:00Z",
"newConfirmed": 6111
}]
I am using Logic App and task is to make an HTTP call, get JSON , read 1 record of json at a time , insert into DB and repeat.
Output of this HTTP call is a json array:
[
{
"id": 1,
"name": "Leanne Graham",
"username": "Bret",
"email": "Sincere#april.biz",
"address": {
"street": "Kulas Light",
"suite": "Apt. 556",
"city": "Gwenborough",
"zipcode": "92998-3874",
"geo": {
"lat": "-37.3159",
"lng": "81.1496"
}
},
"phone": "1-770-736-8031 x56442",
"website": "hildegard.org",
"company": {
"name": "Romaguera-Crona",
"catchPhrase": "Multi-layered client-server neural-net",
"bs": "harness real-time e-markets"
}
},
{
"id": 2,
"name": "Ervin Howell",
"username": "Antonette",
"email": "Shanna#melissa.tv",
"address": {
"street": "Victor Plains",
"suite": "Suite 879",
"city": "Wisokyburgh",
"zipcode": "90566-7771",
"geo": {
"lat": "-43.9509",
"lng": "-34.4618"
}
},
"phone": "010-692-6593 x09125",
"website": "anastasia.net",
"company": {
"name": "Deckow-Crist",
"catchPhrase": "Proactive didactic contingency",
"bs": "synergize scalable supply-chains"
}
},
{
"id": 3,
"name": "Clementine Bauch",
"username": "Samantha",
"email": "Nathan#yesenia.net",
"address": {
"street": "Douglas Extension",
"suite": "Suite 847",
"city": "McKenziehaven",
"zipcode": "59590-4157",
"geo": {
"lat": "-68.6102",
"lng": "-47.0653"
}
},
"phone": "1-463-123-4447",
"website": "ramiro.info",
"company": {
"name": "Romaguera-Jacobson",
"catchPhrase": "Face to face bifurcated interface",
"bs": "e-enable strategic applications"
}
},
{
"id": 4,
"name": "Patricia Lebsack",
"username": "Karianne",
"email": "Julianne.OConner#kory.org",
"address": {
"street": "Hoeger Mall",
"suite": "Apt. 692",
"city": "South Elvis",
"zipcode": "53919-4257",
"geo": {
"lat": "29.4572",
"lng": "-164.2990"
}
},
"phone": "493-170-9623 x156",
"website": "kale.biz",
"company": {
"name": "Robel-Corkery",
"catchPhrase": "Multi-tiered zero tolerance productivity",
"bs": "transition cutting-edge web services"
}
},
{
"id": 5,
"name": "Chelsey Dietrich",
"username": "Kamren",
"email": "Lucio_Hettinger#annie.ca",
"address": {
"street": "Skiles Walks",
"suite": "Suite 351",
"city": "Roscoeview",
"zipcode": "33263",
"geo": {
"lat": "-31.8129",
"lng": "62.5342"
}
},
"phone": "(254)954-1289",
"website": "demarco.info",
"company": {
"name": "Keebler LLC",
"catchPhrase": "User-centric fault-tolerant solution",
"bs": "revolutionize end-to-end systems"
}
},
{
"id": 6,
"name": "Mrs. Dennis Schulist",
"username": "Leopoldo_Corkery",
"email": "Karley_Dach#jasper.info",
"address": {
"street": "Norberto Crossing",
"suite": "Apt. 950",
"city": "South Christy",
"zipcode": "23505-1337",
"geo": {
"lat": "-71.4197",
"lng": "71.7478"
}
},
"phone": "1-477-935-8478 x6430",
"website": "ola.org",
"company": {
"name": "Considine-Lockman",
"catchPhrase": "Synchronised bottom-line interface",
"bs": "e-enable innovative applications"
}
},
{
"id": 7,
"name": "Kurtis Weissnat",
"username": "Elwyn.Skiles",
"email": "Telly.Hoeger#billy.biz",
"address": {
"street": "Rex Trail",
"suite": "Suite 280",
"city": "Howemouth",
"zipcode": "58804-1099",
"geo": {
"lat": "24.8918",
"lng": "21.8984"
}
},
"phone": "210.067.6132",
"website": "elvis.io",
"company": {
"name": "Johns Group",
"catchPhrase": "Configurable multimedia task-force",
"bs": "generate enterprise e-tailers"
}
},
{
"id": 8,
"name": "Nicholas Runolfsdottir V",
"username": "Maxime_Nienow",
"email": "Sherwood#rosamond.me",
"address": {
"street": "Ellsworth Summit",
"suite": "Suite 729",
"city": "Aliyaview",
"zipcode": "45169",
"geo": {
"lat": "-14.3990",
"lng": "-120.7677"
}
},
"phone": "586.493.6943 x140",
"website": "jacynthe.com",
"company": {
"name": "Abernathy Group",
"catchPhrase": "Implemented secondary concept",
"bs": "e-enable extensible e-tailers"
}
},
{
"id": 9,
"name": "Glenna Reichert",
"username": "Delphine",
"email": "Chaim_McDermott#dana.io",
"address": {
"street": "Dayna Park",
"suite": "Suite 449",
"city": "Bartholomebury",
"zipcode": "76495-3109",
"geo": {
"lat": "24.6463",
"lng": "-168.8889"
}
},
"phone": "(775)976-6794 x41206",
"website": "conrad.com",
"company": {
"name": "Yost and Sons",
"catchPhrase": "Switchable contextually-based project",
"bs": "aggregate real-time technologies"
}
},
{
"id": 10,
"name": "Clementina DuBuque",
"username": "Moriah.Stanton",
"email": "Rey.Padberg#karina.biz",
"address": {
"street": "Kattie Turnpike",
"suite": "Suite 198",
"city": "Lebsackbury",
"zipcode": "31428-2261",
"geo": {
"lat": "-38.2386",
"lng": "57.2232"
}
},
"phone": "024-648-3804",
"website": "ambrose.net",
"company": {
"name": "Hoeger LLC",
"catchPhrase": "Centralized empowering task-force",
"bs": "target end-to-end models"
}
}
]
The output can be seen at this url also: https://jsonplaceholder.typicode.com/users
Now in this json array I need to pick 1 record at a time, insert that into DB.
I tried pass output of HTTP 'Body' to JsonParse().
I also tried pass output of HTTP 'Body' to Initialize variable and then foreach control but no success.
If you are using the HTTP action to get the json value, you don't need to parse it to json, the output supports select property.
And in my test I could get the value, so I believe you used a wrong expression. Cause the json items are stored as array, so you need pick the index firstly then select the property. You could use body('HTTP')[1]['name'] to get property value, and if you want to get a item just delete name with body('HTTP')[1] to implement it.
Without property, just pick the second item.
I am new to Angular js. Have a task of parsing nested array of json objects using typescripts and show it in primeng table. Primeng is absolutely new. I am able to show flat structure json, but this nested array of objects are creating problem.
I need to show it in some master-detail relationship.
Below is the JSON structure:
[
{
"baId": "50509060-48e5-4241-a346-f834b22bf4b5",
"status": "Pending",
"legalName": "Koch Suppy and Trading LLP",
"internal": true,
"baType": "Vendor",
"creditAddress": [
{
"addressSubType": "USA",
"addressLine1": "F-35 10th Main",
"addressLine2": "5th Cross Avenue",
"city": "Los Angeles",
"county": "Los Angeles",
"state": "California",
"country": "US",
"postalCode": "90001",
"notes": "District 10"
}
],
"invoiceAddress": [
{
"addressSubType": "USA",
"addressLine1": "F-35 10th Main",
"addressLine2": "5th Cross Avenue",
"city": "Los Angeles",
"county": "Los Angeles",
"state": "California",
"country": "US",
"postalCode": "90001",
"notes": "District 10"
}
],
"finance": [
{
"bank": "Citi Bank",
"routingNumber": "C044072324",
"accountNumber": "000123456789",
"wireTransferMethod": "RTGS",
"intermediaryBank": "Citi Bank",
"intermediaryRoutingNumber": "C044072327",
"intermediaryAccountNumber": "000123456789",
"locationName": "Wichita"
}
],
"reportingTags": [
{
"leiName": "Koch Suppy and Trading LLP",
"leiNumber": "5299001hxs",
"782a": "54-2024246",
"782aCountryIdentifier": "US",
"782c": "1905-0174",
"782cCountryIdentifier": "US",
"cftcClassifications": "Disaggregated Futures",
"cftcReporting": "Long Format",
"cftcSefAssoc": "360 Trading Networks, Inc.",
"emirCategorization": "Financial Counterparties",
"epaCountryIdentifier": "US",
"epaNumber": "1234-000",
"mifidClassifications": "Retail Clients",
"rfcCode": "EOPAN006",
"rfcCodeCountryIdentifier": "US",
"cpCode": "AS101",
"systemSpecific": "AEDP"
}
],
"audit": {
"createdBy": "koch\\malhota1",
"modifiedBy": "koch\\malhota1",
"creationDate": "2017-10-20T16:00:00Z",
"modificationDate": "2027-10-20T16:00:00Z",
"isCurrent": true
}
}
]
Please help me in creating a angular project with primeng from scratch using above json. Appreciate the quick help.
I have the following object. How do I get the email value from it?
{
"payment_method": "paypal",
"payer_info": {
"email": "example#domain.com",
"first_name": "example",
"last_name": "xxx",
"payer_id": "12313213",
"shipping_address": {
"recipient_name": "Example",
"id": "5435345",
"line1": "1 SS ",
"city": "San Jose",
"state": "CA",
"postal_code": "95131",
"country_code": "US"
},
"phone": "4547567",
"country_code": "US"
}
}