Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
{
"destination_addresses" : [
"585 Schenectady Ave, Brooklyn, NY 11203, USA",
"102-01 66th Rd, Queens, NY 11375, USA",
"1000 N Village Ave, Rockville Centre, NY 11570, USA",
"327 Beach 19th St, Far Rockaway, NY 11691, USA"
],
"origin_addresses" : [ "P.O. Box 793, Brooklyn, NY 11207, USA" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "5.4 km",
"value" : 5407
},
"duration" : {
"text" : "19 mins",
"value" : 1139
},
"status" : "OK"
},
{
"distance" : {
"text" : "13.7 km",
"value" : 13744
},
"duration" : {
"text" : "24 mins",
"value" : 1413
},
"status" : "OK"
},
{
"distance" : {
"text" : "25.5 km",
"value" : 25531
},
"duration" : {
"text" : "31 mins",
"value" : 1843
},
"status" : "OK"
},
{
"distance" : {
"text" : "21.3 km",
"value" : 21304
},
"duration" : {
"text" : "35 mins",
"value" : 2116
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}
Si it possible to extract this JSON using tExtractJsonFields, for each destination addresses with the distance and duration data.
An easy way to identify the paths that you will need is to use.....
https://jsonpathfinder.com/
Paste your JSON in there and you can click on the record to see the path that you will need. It is also a nice way of understanding the structure. Your "Loop Jsonpath query" for iterating over the elements there will be.....
$.destination_addresses[*]
Yes, you can do this. But this JSON is rather strangely formatted if the first address in the destination addresses array corresponds to the first elements array's complex type. I presume that there can also be other origin_addresses (given that is an array as well). In order to extract this information you will need to know exactly which array elements you are looking at. So I would use 4 tExtractJSONFields components. 1 for each array. I would extract the "destination_addresses" elements and number them. I would then extract the "origin_addresses" elements and number them. Then I would (in another SubJob) extract the "rows" elements, number them and then pass the data to another tExtractJSONFields component and extract the "elements" elements and number them. This will give you a link between origins, destinations and origin-->destination metrics using the numbering. So, if you have 4 destinations and 4 origins, to find the distance between destination 3 and origin 1, you would look at "rows" 1 and "elements" 3 for the time and distance.
extract the "destination_addresses" elements and number them? Can you provide the expression to use in the tExtractJSONFields component
An easy way to identify the paths that you will need is to use.....
https://jsonpathfinder.com/
Paste your JSON in there and you can click on the record to see the path that you will need. It is also a nice way of understanding the structure. Your "Loop Jsonpath query" for iterating over the elements there will be.....
$.destination_addresses[*]