I have the following code to grab the JSON response from the Zomato API.
// Zomato
function zomatoStart(){
var client = zomato.createClient({
userKey: apiKeyZmato
});
client.getGeocode({
lat: latLocation, //latitude
lon: longLocation, //longitude
}, function(err, result){
if(!err){
var jsonContent = JSON.parse(result);
console.log(jsonContent.nearby_restaurants[0]);
}else {
console.log(err);
}
});
}
The JSON response i get from this is as follows:
{ restaurant:
{ R: { res_id: 16591979 },
apikey: '3fd7e9f90961452a3ffc81ebc6b87513',
id: '16591979',
name: 'Wagaya',
url: 'https://www.zomato.com/brisbane/wagaya-fortitude-valley?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1',
location:
{ address: 'Chinatown Mall, Level 1, 315 Brunswick Street, Fortitude Valley, Brisbane',
locality: 'Chinatown Mall',
city: 'Brisbane',
city_id: 298,
latitude: '-27.4585653042',
longitude: '153.0339020491',
zipcode: '4006',
country_id: 14,
locality_verbose: 'Chinatown Mall, Brisbane' },
switch_to_order_menu: 0,
cuisines: 'Japanese, Sushi',
average_cost_for_two: 100,
price_range: 4,
currency: '$',
offers: [],
opentable_support: 0,
is_zomato_book_res: 0,
mezzo_provider: 'OTHER',
is_book_form_web_view: 0,
book_form_web_view_url: '',
book_again_url: '',
thumb: 'https://b.zmtcdn.com/data/res_imagery/16591979_RESTAURANT_f84903806912e0fb5ce5a7afc437c1af_c.jpg?fit=around%7C200%3A200&crop=200%3A200%3B%2A%2C%2A',
user_rating:
{ aggregate_rating: '4.6',
rating_text: 'Excellent',
rating_color: '3F7E00',
votes: '1411' },
photos_url: 'https://www.zomato.com/brisbane/wagaya-fortitude-valley/photos?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1#tabtop',
menu_url: 'https://www.zomato.com/brisbane/wagaya-fortitude-valley/menu?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1&openSwipeBox=menu&showMinimal=1#tabtop',
featured_image: 'https://b.zmtcdn.com/data/res_imagery/16591979_RESTAURANT_f84903806912e0fb5ce5a7afc437c1af_c.jpg',
has_online_delivery: 0,
is_delivering_now: 0,
include_bogo_offers: true,
deeplink: 'zomato://restaurant/16591979',
is_table_reservation_supported: 0,
has_table_booking: 0,
events_url: 'https://www.zomato.com/brisbane/wagaya-fortitude-valley/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1' } }
I have tried many ways but can not reach the 'latitude' and 'longitude' area of the JSON response i always get a 'TypeError: Cannot read property '........' of undefined'. What line will help me reach this? I thought it would be this but it doesn't work.
jsonContent.nearby_restaurants[0].restaurant[0].location.latitude
Below is the original JSON
{"location":{"entity_type":"subzone","entity_id":98812,"title":"Brisbane CBD","latitude":"-27.4700750000","longitude":"153.0265130000","city_id":298,"city_name":"Brisbane","country_id":14,"country_name":"Australia"},"popularity":{"popularity":"5.00","nightlife_index":"4.49","nearby_res":["16591979","16594096","16613418","16590186","16595540","16590496","16591972","16592280","16591604"],"top_cuisines":["Cafe Food","Coffee and Tea","Modern Australian","Japanese","Sandwich"],"popularity_res":"100","nightlife_res":"10","subzone":"Brisbane CBD","subzone_id":98812,"city":"Brisbane"},"link":"https:\/\/www.zomato.com\/brisbane\/brisbane-cbd-restaurants","nearby_restaurants":[{"restaurant":{"R":{"res_id":16591979},"apikey":"3fd7e9f90961452a3ffc81ebc6b87513","id":"16591979","name":"Wagaya","url":"https:\/\/www.zomato.com\/brisbane\/wagaya-fortitude-valley?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","location":{"address":"Chinatown Mall, Level 1, 315 Brunswick Street, Fortitude Valley, Brisbane","locality":"Chinatown Mall","city":"Brisbane","city_id":298,"latitude":"-27.4585653042","longitude":"153.0339020491","zipcode":"4006","country_id":14,"locality_verbose":"Chinatown Mall, Brisbane"},"switch_to_order_menu":0,"cuisines":"Japanese, Sushi","average_cost_for_two":100,"price_range":4,"currency":"$","offers":[],"opentable_support":0,"is_zomato_book_res":0,"mezzo_provider":"OTHER","is_book_form_web_view":0,"book_form_web_view_url":"","book_again_url":"","thumb":"https:\/\/b.zmtcdn.com\/data\/res_imagery\/16591979_RESTAURANT_f84903806912e0fb5ce5a7afc437c1af_c.jpg?fit=around%7C200%3A200&crop=200%3A200%3B%2A%2C%2A","user_rating":{"aggregate_rating":"4.6","rating_text":"Excellent","rating_color":"3F7E00","votes":"1411"},"photos_url":"https:\/\/www.zomato.com\/brisbane\/wagaya-fortitude-valley\/photos?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1#tabtop","menu_url":"https:\/\/www.zomato.com\/brisbane\/wagaya-fortitude-valley\/menu?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1&openSwipeBox=menu&showMinimal=1#tabtop","featured_image":"https:\/\/b.zmtcdn.com\/data\/res_imagery\/16591979_RESTAURANT_f84903806912e0fb5ce5a7afc437c1af_c.jpg","has_online_delivery":0,"is_delivering_now":0,"include_bogo_offers":true,"deeplink":"zomato:\/\/restaurant\/16591979","is_table_reservation_supported":0,"has_table_booking":0,"events_url":"https:\/\/www.zomato.com\/brisbane\/wagaya-fortitude-valley\/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"}},{"restaurant":{"R":{"res_id":16594096},"apikey":"3fd7e9f90961452a3ffc81ebc6b87513","id":"16594096","name":"Miel Container","url":"https:\/\/www.zomato.com\/brisbane\/miel-container-brisbane-cbd?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","location":{"address":"Corner Of Mary Street and Albert Street, Brisbane CBD, Brisbane","locality":"Brisbane CBD","city":"Brisbane","city_id":298,"latitude":"-27.4720173817","longitude":"153.0271288008","zipcode":"4000","country_id":14,"locality_verbose":"Brisbane CBD, Brisbane"},"switch_to_order_menu":0,"cuisines":"Burger","average_cost_for_two":45,"price_range":2,"currency":"$","offers":[],"opentable_support":0,"is_zomato_book_res":0,"mezzo_provider":"OTHER","is_book_form_web_view":0,"book_form_web_view_url":"","book_again_url":"","thumb":"https:\/\/b.zmtcdn.com\/data\/res_imagery\/16594096_CHAIN_fc3bfbd3250c1cbc120f53436e7dafb7.jpg?fit=around%7C200%3A200&crop=200%3A200%3B%2A%2C%2A","user_rating":{"aggregate_rating":"4.8","rating_text":"Excellent","rating_color":"3F7E00","votes":"756"},"photos_url":"https:\/\/www.zomato.com\/brisbane\/miel-container-brisbane-cbd\/photos?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1#tabtop","menu_url":"https:\/\/www.zomato.com\/brisbane\/miel-container-brisbane-cbd\/menu?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1&openSwipeBox=menu&showMinimal=1#tabtop","featured_image":"https:\/\/b.zmtcdn.com\/data\/res_imagery\/16594096_CHAIN_fc3bfbd3250c1cbc120f53436e7dafb7.jpg","has_online_delivery":0,"is_delivering_now":0,"include_bogo_offers":true,"deeplink":"zomato:\/\/restaurant\/16594096","is_table_reservation_supported":0,"has_table_booking":0,"events_url":"https:\/\/www.zomato.com\/brisbane\/miel-container-brisbane-cbd\/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"}},{"restaurant":{"R":{"res_id":16613418},"apikey":"3fd7e9f90961452a3ffc81ebc6b87513","id":"16613418","name":"Oreily's","url":"https:\/\/www.zomato.com\/ballogie-qld\/oreilys-canungra?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","location":{"address":"lamington national park road, Canungra","locality":"Ballogie","city":"Ballogie","city_id":2632,"latitude":"-27.4688800000","longitude":"153.0228270000","zipcode":"4275","country_id":14,"locality_verbose":"Ballogie, Ballogie"},"switch_to_order_menu":0,"cuisines":"Diner, Pizza","average_cost_for_two":20,"price_range":2,"currency":"$","offers":[],"opentable_support":0,"is_zomato_book_res":0,"mezzo_provider":"OTHER","is_book_form_web_view":0,"book_form_web_view_url":"","book_again_url":"","thumb":"","user_rating":{"aggregate_rating":"0","rating_text":"Not rated","rating_color":"CBCBC8","votes":"3"},"photos_url":"https:\/\/www.zomato.com\/ballogie-qld\/oreilys-canungra\/photos?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1#tabtop","menu_url":"https:\/\/www.zomato.com\/ballogie-qld\/oreilys-canungra\/menu?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1&openSwipeBox=menu&showMinimal=1#tabtop","featured_image":"","has_online_delivery":0,"is_delivering_now":0,"include_bogo_offers":true,"deeplink":"zomato:\/\/restaurant\/16613418","is_table_reservation_supported":0,"has_table_booking":0,"events_url":"https:\/\/www.zomato.com\/ballogie-qld\/oreilys-canungra\/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"}},{"restaurant":{"R":{"res_id":16590186},"apikey":"3fd7e9f90961452a3ffc81ebc6b87513","id":"16590186","name":"The Little Larder","url":"https:\/\/www.zomato.com\/brisbane\/the-little-larder-new-farm?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","location":{"address":"76 Moray Street, New Farm, Brisbane","locality":"New Farm","city":"Brisbane","city_id":298,"latitude":"-27.4668775902","longitude":"153.0412295088","zipcode":"4005","country_id":14,"locality_verbose":"New Farm, Brisbane"},"switch_to_order_menu":0,"cuisines":"Cafe Food","average_cost_for_two":55,"price_range":2,"currency":"$","offers":[],"opentable_support":0,"is_zomato_book_res":0,"mezzo_provider":"OTHER","is_book_form_web_view":0,"book_form_web_view_url":"","book_again_url":"","thumb":"https:\/\/b.zmtcdn.com\/data\/pictures\/6\/16590186\/f032aa278c03ed8a4608a1b73680d4c0.jpg?fit=around%7C200%3A200&crop=200%3A200%3B%2A%2C%2A","user_rating":{"aggregate_rating":"4.1","rating_text":"Very Good","rating_color":"5BA829","votes":"803"},"photos_url":"https:\/\/www.zomato.com\/brisbane\/the-little-larder-new-farm\/photos?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1#tabtop","menu_url":"https:\/\/www.zomato.com\/brisbane\/the-little-larder-new-farm\/menu?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1&openSwipeBox=menu&showMinimal=1#tabtop","featured_image":"https:\/\/b.zmtcdn.com\/data\/pictures\/6\/16590186\/f032aa278c03ed8a4608a1b73680d4c0.jpg","has_online_delivery":0,"is_delivering_now":0,"include_bogo_offers":true,"deeplink":"zomato:\/\/restaurant\/16590186","is_table_reservation_supported":0,"has_table_booking":0,"events_url":"https:\/\/www.zomato.com\/brisbane\/the-little-larder-new-farm\/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"}},{"restaurant":{"R":{"res_id":16595540},"apikey":"3fd7e9f90961452a3ffc81ebc6b87513","id":"16595540","name":"Julius Pizzeria","url":"https:\/\/www.zomato.com\/brisbane\/julius-pizzeria-south-brisbane?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","location":{"address":"77 Grey Street, South Brisbane, Brisbane","locality":"South Brisbane","city":"Brisbane","city_id":298,"latitude":"-27.4738750608","longitude":"153.0180431530","zipcode":"4101","country_id":14,"locality_verbose":"South Brisbane, Brisbane"},"switch_to_order_menu":0,"cuisines":"Pizza, Italian","average_cost_for_two":80,"price_range":3,"currency":"$","offers":[],"opentable_support":0,"is_zomato_book_res":0,"mezzo_provider":"OTHER","is_book_form_web_view":0,"book_form_web_view_url":"","book_again_url":"","thumb":"https:\/\/b.zmtcdn.com\/data\/res_imagery\/16595540_RESTAURANT_257641802b0296a6ccb17abfe913776e_c.jpg?fit=around%7C200%3A200&crop=200%3A200%3B%2A%2C%2A","user_rating":{"aggregate_rating":"4.9","rating_text":"Excellent","rating_color":"3F7E00","votes":"342"},"photos_url":"https:\/\/www.zomato.com\/brisbane\/julius-pizzeria-south-brisbane\/photos?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1#tabtop","menu_url":"https:\/\/www.zomato.com\/brisbane\/julius-pizzeria-south-brisbane\/menu?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1&openSwipeBox=menu&showMinimal=1#tabtop","featured_image":"https:\/\/b.zmtcdn.com\/data\/res_imagery\/16595540_RESTAURANT_257641802b0296a6ccb17abfe913776e_c.jpg","has_online_delivery":0,"is_delivering_now":0,"include_bogo_offers":true,"deeplink":"zomato:\/\/restaurant\/16595540","is_table_reservation_supported":0,"has_table_booking":0,"events_url":"https:\/\/www.zomato.com\/brisbane\/julius-pizzeria-south-brisbane\/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"}},{"restaurant":{"R":{"res_id":16590496},"apikey":"3fd7e9f90961452a3ffc81ebc6b87513","id":"16590496","name":"Verve Restaurant Bar Cider House","url":"https:\/\/www.zomato.com\/brisbane\/verve-restaurant-bar-cider-house-brisbane-cbd?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","location":{"address":"109 Edward Street, Brisbane CBD, Brisbane","locality":"Brisbane CBD","city":"Brisbane","city_id":298,"latitude":"-27.4701864440","longitude":"153.0288980529","zipcode":"4001","country_id":14,"locality_verbose":"Brisbane CBD, Brisbane"},"switch_to_order_menu":0,"cuisines":"Italian, Pizza","average_cost_for_two":90,"price_range":3,"currency":"$","offers":[],"opentable_support":0,"is_zomato_book_res":0,"mezzo_provider":"OTHER","is_book_form_web_view":0,"book_form_web_view_url":"","book_again_url":"","thumb":"https:\/\/b.zmtcdn.com\/data\/res_imagery\/16590496_RESTAURANT_d2c6e460dfe43cf9872419e499d09c5a.jpg?fit=around%7C200%3A200&crop=200%3A200%3B%2A%2C%2A","user_rating":{"aggregate_rating":"4.6","rating_text":"Excellent","rating_color":"3F7E00","votes":"965"},"photos_url":"https:\/\/www.zomato.com\/brisbane\/verve-restaurant-bar-cider-house-brisbane-cbd\/photos?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1#tabtop","menu_url":"https:\/\/www.zomato.com\/brisbane\/verve-restaurant-bar-cider-house-brisbane-cbd\/menu?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1&openSwipeBox=menu&showMinimal=1#tabtop","featured_image":"https:\/\/b.zmtcdn.com\/data\/res_imagery\/16590496_RESTAURANT_d2c6e460dfe43cf9872419e499d09c5a.jpg","has_online_delivery":0,"is_delivering_now":0,"include_bogo_offers":true,"deeplink":"zomato:\/\/restaurant\/16590496","is_table_reservation_supported":0,"has_table_booking":0,"events_url":"https:\/\/www.zomato.com\/brisbane\/verve-restaurant-bar-cider-house-brisbane-cbd\/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"}},{"restaurant":{"R":{"res_id":16591972},"apikey":"3fd7e9f90961452a3ffc81ebc6b87513","id":"16591972","name":"Malt Dining","url":"https:\/\/www.zomato.com\/brisbane\/malt-dining-brisbane-cbd?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","location":{"address":"28 Market Street, Brisbane CBD, Brisbane","locality":"Brisbane CBD","city":"Brisbane","city_id":298,"latitude":"-27.4695192076","longitude":"153.0294358358","zipcode":"4000","country_id":14,"locality_verbose":"Brisbane CBD, Brisbane"},"switch_to_order_menu":0,"cuisines":"Modern Australian","average_cost_for_two":140,"price_range":4,"currency":"$","offers":[],"opentable_support":0,"is_zomato_book_res":0,"mezzo_provider":"DIMMI","is_book_form_web_view":0,"book_form_web_view_url":"","thumb":"https:\/\/b.zmtcdn.com\/data\/res_imagery\/16591972_RESTAURANT_bb12785af23666f2718b5d7e12c9a9bf.jpg?fit=around%7C200%3A200&crop=200%3A200%3B%2A%2C%2A","user_rating":{"aggregate_rating":"4.6","rating_text":"Excellent","rating_color":"3F7E00","votes":"777"},"photos_url":"https:\/\/www.zomato.com\/brisbane\/malt-dining-brisbane-cbd\/photos?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1#tabtop","menu_url":"https:\/\/www.zomato.com\/brisbane\/malt-dining-brisbane-cbd\/menu?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1&openSwipeBox=menu&showMinimal=1#tabtop","featured_image":"https:\/\/b.zmtcdn.com\/data\/res_imagery\/16591972_RESTAURANT_bb12785af23666f2718b5d7e12c9a9bf.jpg","medio_provider":"","has_online_delivery":0,"is_delivering_now":0,"include_bogo_offers":true,"deeplink":"zomato:\/\/restaurant\/16591972","is_table_reservation_supported":1,"has_table_booking":1,"book_url":"https:\/\/www.zomato.com\/brisbane\/malt-dining-brisbane-cbd\/book?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","events_url":"https:\/\/www.zomato.com\/brisbane\/malt-dining-brisbane-cbd\/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"}},{"restaurant":{"R":{"res_id":16592280},"apikey":"3fd7e9f90961452a3ffc81ebc6b87513","id":"16592280","name":"Maru Korean BBQ","url":"https:\/\/www.zomato.com\/brisbane\/maru-korean-bbq-brisbane-cbd?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","location":{"address":"157 Elizabeth Street, Brisbane CBD, Brisbane","locality":"Brisbane CBD","city":"Brisbane","city_id":298,"latitude":"-27.4703619536","longitude":"153.0266862363","zipcode":"4000","country_id":14,"locality_verbose":"Brisbane CBD, Brisbane"},"switch_to_order_menu":0,"cuisines":"Korean BBQ","average_cost_for_two":70,"price_range":3,"currency":"$","offers":[],"opentable_support":0,"is_zomato_book_res":0,"mezzo_provider":"OTHER","is_book_form_web_view":0,"book_form_web_view_url":"","book_again_url":"","thumb":"https:\/\/b.zmtcdn.com\/data\/res_imagery\/16592280_RESTAURANT_b5b0b29ad344a66fe7b231a2310df243.jpg?fit=around%7C200%3A200&crop=200%3A200%3B%2A%2C%2A","user_rating":{"aggregate_rating":"4.2","rating_text":"Very Good","rating_color":"5BA829","votes":"459"},"photos_url":"https:\/\/www.zomato.com\/brisbane\/maru-korean-bbq-brisbane-cbd\/photos?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1#tabtop","menu_url":"https:\/\/www.zomato.com\/brisbane\/maru-korean-bbq-brisbane-cbd\/menu?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1&openSwipeBox=menu&showMinimal=1#tabtop","featured_image":"https:\/\/b.zmtcdn.com\/data\/res_imagery\/16592280_RESTAURANT_b5b0b29ad344a66fe7b231a2310df243.jpg","has_online_delivery":0,"is_delivering_now":0,"include_bogo_offers":true,"deeplink":"zomato:\/\/restaurant\/16592280","is_table_reservation_supported":0,"has_table_booking":0,"events_url":"https:\/\/www.zomato.com\/brisbane\/maru-korean-bbq-brisbane-cbd\/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"}},{"restaurant":{"R":{"res_id":16591604},"apikey":"3fd7e9f90961452a3ffc81ebc6b87513","id":"16591604","name":"Sak\u00e9 Restaurant & Bar","url":"https:\/\/www.zomato.com\/brisbane\/sak\u00e9-restaurant-bar-brisbane-cbd?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","location":{"address":"45 Eagle Street Pier, Brisbane CBD, Brisbane","locality":"Eagle Street Pier","city":"Brisbane","city_id":298,"latitude":"-27.4689676860","longitude":"153.0305147544","zipcode":"4000","country_id":14,"locality_verbose":"Eagle Street Pier, Brisbane"},"switch_to_order_menu":0,"cuisines":"Japanese, Sushi","average_cost_for_two":160,"price_range":4,"currency":"$","offers":[],"opentable_support":0,"is_zomato_book_res":0,"mezzo_provider":"DIMMI","is_book_form_web_view":0,"book_form_web_view_url":"","thumb":"https:\/\/b.zmtcdn.com\/data\/res_imagery\/16561824_CHAIN_91355653f1b0d88822f183a572cb5a56.jpg?fit=around%7C200%3A200&crop=200%3A200%3B%2A%2C%2A","user_rating":{"aggregate_rating":"4.5","rating_text":"Excellent","rating_color":"3F7E00","votes":"909"},"photos_url":"https:\/\/www.zomato.com\/brisbane\/sak\u00e9-restaurant-bar-brisbane-cbd\/photos?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1#tabtop","menu_url":"https:\/\/www.zomato.com\/brisbane\/sak\u00e9-restaurant-bar-brisbane-cbd\/menu?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1&openSwipeBox=menu&showMinimal=1#tabtop","featured_image":"https:\/\/b.zmtcdn.com\/data\/res_imagery\/16561824_CHAIN_91355653f1b0d88822f183a572cb5a56.jpg","medio_provider":"","has_online_delivery":0,"is_delivering_now":0,"include_bogo_offers":true,"deeplink":"zomato:\/\/restaurant\/16591604","is_table_reservation_supported":1,"has_table_booking":1,"book_url":"https:\/\/www.zomato.com\/brisbane\/sak\u00e9-restaurant-bar-brisbane-cbd\/book?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1","events_url":"https:\/\/www.zomato.com\/brisbane\/sak\u00e9-restaurant-bar-brisbane-cbd\/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"}}]}
Here is what I have tried in my local machine and it is working fine
let data = {
"location": {
"entity_type": "subzone",
"entity_id": 98812,
"title": "Brisbane CBD",
"latitude": "-27.4700750000",
"longitude": "153.0265130000",
"city_id": 298,
"city_name": "Brisbane",
"country_id": 14,
"country_name": "Australia"
},
"popularity": {
"popularity": "5.00",
"nightlife_index": "4.49",
"nearby_res": [
"16591979",
"16594096",
"16613418",
"16590186",
"16595540",
"16590496",
"16591972",
"16592280",
"16591604"
],
"top_cuisines": [
"Cafe Food",
"Coffee and Tea",
"Modern Australian",
"Japanese",
"Sandwich"
],
"popularity_res": "100",
"nightlife_res": "10",
"subzone": "Brisbane CBD",
"subzone_id": 98812,
"city": "Brisbane"
},
"link": "https:\/\/www.zomato.com\/brisbane\/brisbane-cbd-restaurants",
"nearby_restaurants": [
{
"restaurant": {
"R": {
"res_id": 16591979
},
"apikey": "3fd7e9f90961452a3ffc81ebc6b87513",
"id": "16591979",
"name": "Wagaya",
"url": "https:\/\/www.zomato.com\/brisbane\/wagaya-fortitude-valley?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1",
"location": {
"address": "Chinatown Mall, Level 1, 315 Brunswick Street, Fortitude Valley, Brisbane",
"locality": "Chinatown Mall",
"city": "Brisbane",
"city_id": 298,
"latitude": "-27.4585653042",
"longitude": "153.0339020491",
"zipcode": "4006",
"country_id": 14,
"locality_verbose": "Chinatown Mall, Brisbane"
},
"switch_to_order_menu": 0,
"cuisines": "Japanese, Sushi",
"average_cost_for_two": 100,
"price_range": 4,
"currency": "$",
"offers": [
],
"opentable_support": 0,
"is_zomato_book_res": 0,
"mezzo_provider": "OTHER",
"is_book_form_web_view": 0,
"book_form_web_view_url": "",
"book_again_url": "",
"thumb": "https:\/\/b.zmtcdn.com\/data\/res_imagery\/16591979_RESTAURANT_f84903806912e0fb5ce5a7afc437c1af_c.jpg?fit=around%7C200%3A200&crop=200%3A200%3B%2A%2C%2A",
"user_rating": {
"aggregate_rating": "4.6",
"rating_text": "Excellent",
"rating_color": "3F7E00",
"votes": "1411"
},
"photos_url": "https:\/\/www.zomato.com\/brisbane\/wagaya-fortitude-valley\/photos?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1#tabtop",
"menu_url": "https:\/\/www.zomato.com\/brisbane\/wagaya-fortitude-valley\/menu?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1&openSwipeBox=menu&showMinimal=1#tabtop",
"featured_image": "https:\/\/b.zmtcdn.com\/data\/res_imagery\/16591979_RESTAURANT_f84903806912e0fb5ce5a7afc437c1af_c.jpg",
"has_online_delivery": 0,
"is_delivering_now": 0,
"include_bogo_offers": true,
"deeplink": "zomato:\/\/restaurant\/16591979",
"is_table_reservation_supported": 0,
"has_table_booking": 0,
"events_url": "https:\/\/www.zomato.com\/brisbane\/wagaya-fortitude-valley\/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"
}
},
{
"restaurant": {
"R": {
"res_id": 16594096
},
"apikey": "3fd7e9f90961452a3ffc81ebc6b87513",
"id": "16594096",
"name": "Miel Container",
"url": "https:\/\/www.zomato.com\/brisbane\/miel-container-brisbane-cbd?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1",
"location": {
"address": "Corner Of Mary Street and Albert Street, Brisbane CBD, Brisbane",
"locality": "Brisbane CBD",
"city": "Brisbane",
"city_id": 298,
"latitude": "-27.4720173817",
"longitude": "153.0271288008",
"zipcode": "4000",
"country_id": 14,
"locality_verbose": "Brisbane CBD, Brisbane"
},
"switch_to_order_menu": 0,
"cuisines": "Burger",
"average_cost_for_two": 45,
"price_range": 2,
"currency": "$",
"offers": [
],
"opentable_support": 0,
"is_zomato_book_res": 0,
"mezzo_provider": "OTHER",
"is_book_form_web_view": 0,
"book_form_web_view_url": "",
"book_again_url": "",
"thumb": "https:\/\/b.zmtcdn.com\/data\/res_imagery\/16594096_CHAIN_fc3bfbd3250c1cbc120f53436e7dafb7.jpg?fit=around%7C200%3A200&crop=200%3A200%3B%2A%2C%2A",
"user_rating": {
"aggregate_rating": "4.8",
"rating_text": "Excellent",
"rating_color": "3F7E00",
"votes": "756"
},
"photos_url": "https:\/\/www.zomato.com\/brisbane\/miel-container-brisbane-cbd\/photos?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1#tabtop",
"menu_url": "https:\/\/www.zomato.com\/brisbane\/miel-container-brisbane-cbd\/menu?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1&openSwipeBox=menu&showMinimal=1#tabtop",
"featured_image": "https:\/\/b.zmtcdn.com\/data\/res_imagery\/16594096_CHAIN_fc3bfbd3250c1cbc120f53436e7dafb7.jpg",
"has_online_delivery": 0,
"is_delivering_now": 0,
"include_bogo_offers": true,
"deeplink": "zomato:\/\/restaurant\/16594096",
"is_table_reservation_supported": 0,
"has_table_booking": 0,
"events_url": "https:\/\/www.zomato.com\/brisbane\/miel-container-brisbane-cbd\/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"
}
},
{
"restaurant": {
"R": {
"res_id": 16613418
},
"apikey": "3fd7e9f90961452a3ffc81ebc6b87513",
"id": "16613418",
"name": "Oreily's",
"url": "https:\/\/www.zomato.com\/ballogie-qld\/oreilys-canungra?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1",
"location": {
"address": "lamington national park road, Canungra",
"locality": "Ballogie",
"city": "Ballogie",
"city_id": 2632,
"latitude": "-27.4688800000",
"longitude": "153.0228270000",
"zipcode": "4275",
"country_id": 14,
"locality_verbose": "Ballogie, Ballogie"
},
"switch_to_order_menu": 0,
"cuisines": "Diner, Pizza",
"average_cost_for_two": 20,
"price_range": 2,
"currency": "$",
"offers": [
],
"opentable_support": 0,
"is_zomato_book_res": 0,
"mezzo_provider": "OTHER",
"is_book_form_web_view": 0,
"book_form_web_view_url": "",
"book_again_url": "",
"thumb": "",
"user_rating": {
"aggregate_rating": "0",
"rating_text": "Not rated",
"rating_color": "CBCBC8",
"votes": "3"
},
"photos_url": "https:\/\/www.zomato.com\/ballogie-qld\/oreilys-canungra\/photos?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1#tabtop",
"menu_url": "https:\/\/www.zomato.com\/ballogie-qld\/oreilys-canungra\/menu?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1&openSwipeBox=menu&showMinimal=1#tabtop",
"featured_image": "",
"has_online_delivery": 0,
"is_delivering_now": 0,
"include_bogo_offers": true,
"deeplink": "zomato:\/\/restaurant\/16613418",
"is_table_reservation_supported": 0,
"has_table_booking": 0,
"events_url": "https:\/\/www.zomato.com\/ballogie-qld\/oreilys-canungra\/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"
}
},
{
"restaurant": {
"R": {
"res_id": 16590186
},
"apikey": "3fd7e9f90961452a3ffc81ebc6b87513",
"id": "16590186",
"name": "The Little Larder",
"url": "https:\/\/www.zomato.com\/brisbane\/the-little-larder-new-farm?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1",
"location": {
"address": "76 Moray Street, New Farm, Brisbane",
"locality": "New Farm",
"city": "Brisbane",
"city_id": 298,
"latitude": "-27.4668775902",
"longitude": "153.0412295088",
"zipcode": "4005",
"country_id": 14,
"locality_verbose": "New Farm, Brisbane"
},
"switch_to_order_menu": 0,
"cuisines": "Cafe Food",
"average_cost_for_two": 55,
"price_range": 2,
"currency": "$",
"offers": [
],
"opentable_support": 0,
"is_zomato_book_res": 0,
"mezzo_provider": "OTHER",
"is_book_form_web_view": 0,
"book_form_web_view_url": "",
"book_again_url": "",
"thumb": "https:\/\/b.zmtcdn.com\/data\/pictures\/6\/16590186\/f032aa278c03ed8a4608a1b73680d4c0.jpg?fit=around%7C200%3A200&crop=200%3A200%3B%2A%2C%2A",
"user_rating": {
"aggregate_rating": "4.1",
"rating_text": "Very Good",
"rating_color": "5BA829",
"votes": "803"
},
"photos_url": "https:\/\/www.zomato.com\/brisbane\/the-little-larder-new-farm\/photos?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1#tabtop",
"menu_url": "https:\/\/www.zomato.com\/brisbane\/the-little-larder-new-farm\/menu?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1&openSwipeBox=menu&showMinimal=1#tabtop",
"featured_image": "https:\/\/b.zmtcdn.com\/data\/pictures\/6\/16590186\/f032aa278c03ed8a4608a1b73680d4c0.jpg",
"has_online_delivery": 0,
"is_delivering_now": 0,
"include_bogo_offers": true,
"deeplink": "zomato:\/\/restaurant\/16590186",
"is_table_reservation_supported": 0,
"has_table_booking": 0,
"events_url": "https:\/\/www.zomato.com\/brisbane\/the-little-larder-new-farm\/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"
}
},
{
"restaurant": {
"R": {
"res_id": 16595540
},
"apikey": "3fd7e9f90961452a3ffc81ebc6b87513",
"id": "16595540",
"name": "Julius Pizzeria",
"url": "https:\/\/www.zomato.com\/brisbane\/julius-pizzeria-south-brisbane?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1",
"location": {
"address": "77 Grey Street, South Brisbane, Brisbane",
"locality": "South Brisbane",
"city": "Brisbane",
"city_id": 298,
"latitude": "-27.4738750608",
"longitude": "153.0180431530",
"zipcode": "4101",
"country_id": 14,
"locality_verbose": "South Brisbane, Brisbane"
},
"switch_to_order_menu": 0,
"cuisines": "Pizza, Italian",
"average_cost_for_two": 80,
"price_range": 3,
"currency": "$",
"offers": [
],
"opentable_support": 0,
"is_zomato_book_res": 0,
"mezzo_provider": "OTHER",
"is_book_form_web_view": 0,
"book_form_web_view_url": "",
"book_again_url": "",
"thumb": "https:\/\/b.zmtcdn.com\/data\/res_imagery\/16595540_RESTAURANT_257641802b0296a6ccb17abfe913776e_c.jpg?fit=around%7C200%3A200&crop=200%3A200%3B%2A%2C%2A",
"user_rating": {
"aggregate_rating": "4.9",
"rating_text": "Excellent",
"rating_color": "3F7E00",
"votes": "342"
},
"photos_url": "https:\/\/www.zomato.com\/brisbane\/julius-pizzeria-south-brisbane\/photos?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1#tabtop",
"menu_url": "https:\/\/www.zomato.com\/brisbane\/julius-pizzeria-south-brisbane\/menu?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1&openSwipeBox=menu&showMinimal=1#tabtop",
"featured_image": "https:\/\/b.zmtcdn.com\/data\/res_imagery\/16595540_RESTAURANT_257641802b0296a6ccb17abfe913776e_c.jpg",
"has_online_delivery": 0,
"is_delivering_now": 0,
"include_bogo_offers": true,
"deeplink": "zomato:\/\/restaurant\/16595540",
"is_table_reservation_supported": 0,
"has_table_booking": 0,
"events_url": "https:\/\/www.zomato.com\/brisbane\/julius-pizzeria-south-brisbane\/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"
}
},
{
"restaurant": {
"R": {
"res_id": 16590496
},
"apikey": "3fd7e9f90961452a3ffc81ebc6b87513",
"id": "16590496",
"name": "Verve Restaurant Bar Cider House",
"url": "https:\/\/www.zomato.com\/brisbane\/verve-restaurant-bar-cider-house-brisbane-cbd?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1",
"location": {
"address": "109 Edward Street, Brisbane CBD, Brisbane",
"locality": "Brisbane CBD",
"city": "Brisbane",
"city_id": 298,
"latitude": "-27.4701864440",
"longitude": "153.0288980529",
"zipcode": "4001",
"country_id": 14,
"locality_verbose": "Brisbane CBD, Brisbane"
},
"switch_to_order_menu": 0,
"cuisines": "Italian, Pizza",
"average_cost_for_two": 90,
"price_range": 3,
"currency": "$",
"offers": [
],
"opentable_support": 0,
"is_zomato_book_res": 0,
"mezzo_provider": "OTHER",
"is_book_form_web_view": 0,
"book_form_web_view_url": "",
"book_again_url": "",
"thumb": "https:\/\/b.zmtcdn.com\/data\/res_imagery\/16590496_RESTAURANT_d2c6e460dfe43cf9872419e499d09c5a.jpg?fit=around%7C200%3A200&crop=200%3A200%3B%2A%2C%2A",
"user_rating": {
"aggregate_rating": "4.6",
"rating_text": "Excellent",
"rating_color": "3F7E00",
"votes": "965"
},
"photos_url": "https:\/\/www.zomato.com\/brisbane\/verve-restaurant-bar-cider-house-brisbane-cbd\/photos?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1#tabtop",
"menu_url": "https:\/\/www.zomato.com\/brisbane\/verve-restaurant-bar-cider-house-brisbane-cbd\/menu?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1&openSwipeBox=menu&showMinimal=1#tabtop",
"featured_image": "https:\/\/b.zmtcdn.com\/data\/res_imagery\/16590496_RESTAURANT_d2c6e460dfe43cf9872419e499d09c5a.jpg",
"has_online_delivery": 0,
"is_delivering_now": 0,
"include_bogo_offers": true,
"deeplink": "zomato:\/\/restaurant\/16590496",
"is_table_reservation_supported": 0,
"has_table_booking": 0,
"events_url": "https:\/\/www.zomato.com\/brisbane\/verve-restaurant-bar-cider-house-brisbane-cbd\/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"
}
},
{
"restaurant": {
"R": {
"res_id": 16591972
},
"apikey": "3fd7e9f90961452a3ffc81ebc6b87513",
"id": "16591972",
"name": "Malt Dining",
"url": "https:\/\/www.zomato.com\/brisbane\/malt-dining-brisbane-cbd?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1",
"location": {
"address": "28 Market Street, Brisbane CBD, Brisbane",
"locality": "Brisbane CBD",
"city": "Brisbane",
"city_id": 298,
"latitude": "-27.4695192076",
"longitude": "153.0294358358",
"zipcode": "4000",
"country_id": 14,
"locality_verbose": "Brisbane CBD, Brisbane"
},
"switch_to_order_menu": 0,
"cuisines": "Modern Australian",
"average_cost_for_two": 140,
"price_range": 4,
"currency": "$",
"offers": [
],
"opentable_support": 0,
"is_zomato_book_res": 0,
"mezzo_provider": "DIMMI",
"is_book_form_web_view": 0,
"book_form_web_view_url": "",
"thumb": "https:\/\/b.zmtcdn.com\/data\/res_imagery\/16591972_RESTAURANT_bb12785af23666f2718b5d7e12c9a9bf.jpg?fit=around%7C200%3A200&crop=200%3A200%3B%2A%2C%2A",
"user_rating": {
"aggregate_rating": "4.6",
"rating_text": "Excellent",
"rating_color": "3F7E00",
"votes": "777"
},
"photos_url": "https:\/\/www.zomato.com\/brisbane\/malt-dining-brisbane-cbd\/photos?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1#tabtop",
"menu_url": "https:\/\/www.zomato.com\/brisbane\/malt-dining-brisbane-cbd\/menu?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1&openSwipeBox=menu&showMinimal=1#tabtop",
"featured_image": "https:\/\/b.zmtcdn.com\/data\/res_imagery\/16591972_RESTAURANT_bb12785af23666f2718b5d7e12c9a9bf.jpg",
"medio_provider": "",
"has_online_delivery": 0,
"is_delivering_now": 0,
"include_bogo_offers": true,
"deeplink": "zomato:\/\/restaurant\/16591972",
"is_table_reservation_supported": 1,
"has_table_booking": 1,
"book_url": "https:\/\/www.zomato.com\/brisbane\/malt-dining-brisbane-cbd\/book?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1",
"events_url": "https:\/\/www.zomato.com\/brisbane\/malt-dining-brisbane-cbd\/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"
}
},
{
"restaurant": {
"R": {
"res_id": 16592280
},
"apikey": "3fd7e9f90961452a3ffc81ebc6b87513",
"id": "16592280",
"name": "Maru Korean BBQ",
"url": "https:\/\/www.zomato.com\/brisbane\/maru-korean-bbq-brisbane-cbd?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1",
"location": {
"address": "157 Elizabeth Street, Brisbane CBD, Brisbane",
"locality": "Brisbane CBD",
"city": "Brisbane",
"city_id": 298,
"latitude": "-27.4703619536",
"longitude": "153.0266862363",
"zipcode": "4000",
"country_id": 14,
"locality_verbose": "Brisbane CBD, Brisbane"
},
"switch_to_order_menu": 0,
"cuisines": "Korean BBQ",
"average_cost_for_two": 70,
"price_range": 3,
"currency": "$",
"offers": [
],
"opentable_support": 0,
"is_zomato_book_res": 0,
"mezzo_provider": "OTHER",
"is_book_form_web_view": 0,
"book_form_web_view_url": "",
"book_again_url": "",
"thumb": "https:\/\/b.zmtcdn.com\/data\/res_imagery\/16592280_RESTAURANT_b5b0b29ad344a66fe7b231a2310df243.jpg?fit=around%7C200%3A200&crop=200%3A200%3B%2A%2C%2A",
"user_rating": {
"aggregate_rating": "4.2",
"rating_text": "Very Good",
"rating_color": "5BA829",
"votes": "459"
},
"photos_url": "https:\/\/www.zomato.com\/brisbane\/maru-korean-bbq-brisbane-cbd\/photos?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1#tabtop",
"menu_url": "https:\/\/www.zomato.com\/brisbane\/maru-korean-bbq-brisbane-cbd\/menu?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1&openSwipeBox=menu&showMinimal=1#tabtop",
"featured_image": "https:\/\/b.zmtcdn.com\/data\/res_imagery\/16592280_RESTAURANT_b5b0b29ad344a66fe7b231a2310df243.jpg",
"has_online_delivery": 0,
"is_delivering_now": 0,
"include_bogo_offers": true,
"deeplink": "zomato:\/\/restaurant\/16592280",
"is_table_reservation_supported": 0,
"has_table_booking": 0,
"events_url": "https:\/\/www.zomato.com\/brisbane\/maru-korean-bbq-brisbane-cbd\/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"
}
},
{
"restaurant": {
"R": {
"res_id": 16591604
},
"apikey": "3fd7e9f90961452a3ffc81ebc6b87513",
"id": "16591604",
"name": "Sak\u00e9 Restaurant & Bar",
"url": "https:\/\/www.zomato.com\/brisbane\/sak\u00e9-restaurant-bar-brisbane-cbd?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1",
"location": {
"address": "45 Eagle Street Pier, Brisbane CBD, Brisbane",
"locality": "Eagle Street Pier",
"city": "Brisbane",
"city_id": 298,
"latitude": "-27.4689676860",
"longitude": "153.0305147544",
"zipcode": "4000",
"country_id": 14,
"locality_verbose": "Eagle Street Pier, Brisbane"
},
"switch_to_order_menu": 0,
"cuisines": "Japanese, Sushi",
"average_cost_for_two": 160,
"price_range": 4,
"currency": "$",
"offers": [
],
"opentable_support": 0,
"is_zomato_book_res": 0,
"mezzo_provider": "DIMMI",
"is_book_form_web_view": 0,
"book_form_web_view_url": "",
"thumb": "https:\/\/b.zmtcdn.com\/data\/res_imagery\/16561824_CHAIN_91355653f1b0d88822f183a572cb5a56.jpg?fit=around%7C200%3A200&crop=200%3A200%3B%2A%2C%2A",
"user_rating": {
"aggregate_rating": "4.5",
"rating_text": "Excellent",
"rating_color": "3F7E00",
"votes": "909"
},
"photos_url": "https:\/\/www.zomato.com\/brisbane\/sak\u00e9-restaurant-bar-brisbane-cbd\/photos?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1#tabtop",
"menu_url": "https:\/\/www.zomato.com\/brisbane\/sak\u00e9-restaurant-bar-brisbane-cbd\/menu?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1&openSwipeBox=menu&showMinimal=1#tabtop",
"featured_image": "https:\/\/b.zmtcdn.com\/data\/res_imagery\/16561824_CHAIN_91355653f1b0d88822f183a572cb5a56.jpg",
"medio_provider": "",
"has_online_delivery": 0,
"is_delivering_now": 0,
"include_bogo_offers": true,
"deeplink": "zomato:\/\/restaurant\/16591604",
"is_table_reservation_supported": 1,
"has_table_booking": 1,
"book_url": "https:\/\/www.zomato.com\/brisbane\/sak\u00e9-restaurant-bar-brisbane-cbd\/book?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1",
"events_url": "https:\/\/www.zomato.com\/brisbane\/sak\u00e9-restaurant-bar-brisbane-cbd\/events#tabtop?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1"
}
}
]
}
data.nearby_restaurants.map((d, i) => {
if(d.restaurant){
console.log("Latitude", d.restaurant.location.latitude);
console.log("Longitude", d.restaurant.location.longitude);
}
});
Related
I am new to SwiftUI and have been stuck for days in trying to map my backend API's JSON object into the SwitchUI Model (Which I think is the right way to approach this type of problem?). I am getting error while trying to initalize the variable.
I am trying to use Alamofire to get the response from my API in JSON and map that to a Published variable so I can print the list of businesses as the result.
The following is what I have and the I'm getting the
"Missing argument for parameter 'from' in call" error
on the line: #Published var result: Result = Result()
If I make the "[Businesses] and region" in my model as Optional, then I can't see them in the view. What is wrong here?
Thanks very much
View
class SearchFormModel: ObservableObject {
#Published var result: Result = Result()
AF.request(backendApiURL, parameters: parameters).responseDecodable(of: Result.self) { response in
debugPrint("Response:\(response)")
switch response.result {
case let .success(value):
self.result = value
print(value)
case let .failure(error):
print(error)
}
Model
import Foundation
import SwiftyJSON
struct Result: Codable {
var businesses : [Businesses]
var region : Region
}
struct Businesses: Codable {
var id : String = ""
var alias : String?
var name : String?
var image_url : URL?
var is_closed : Bool?
var url : URL?
var review_count : Int?
var categories : [Categories]?
var rating : Double?
var coordinates : Coordinates?
var transactions : [String]?
var price : String?
var location : Location?
var phone : String?
var display_phone : String?
var distance : Double?
}
struct Categories: Codable {
var alias : String = ""
var title : String = ""
}
struct Coordinates: Codable {
var latitude : Double = 0.0
var longitude : Double = 0.0
}
struct Location: Codable {
var address1 : String?
var address2 : String?
var address3 : String?
var city : String?
var zip_code : String?
var country : String?
var state : String?
var display_address : [String]?
}
struct Region: Codable {
var center : Center
}
struct Center : Codable {
var longitude : Double = 0.0
var latitude : Double = 0.0
}
Sample JSON
{
"businesses": [
{
"id": "aDa5FQZdCghy3XwK_h93Fw",
"alias": "worlds-best-pizza-hacienda-heights",
"name": "World's Best Pizza",
"image_url": "https://s3-media1.fl.yelpcdn.com/bphoto/ZPKyEBB5As3dVberckNyxg/o.jpg",
"is_closed": false,
"url": "https://www.yelp.com/biz/worlds-best-pizza-hacienda-heights?adjust_creative=WpoQHLnOMdOyEndsLlwSPg&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=WpoQHLnOMdOyEndsLlwSPg",
"review_count": 409,
"categories": [
{
"alias": "pizza",
"title": "Pizza"
}
],
"rating": 4.5,
"coordinates": {
"latitude": 33.9801206981514,
"longitude": -117.974323744633
},
"transactions": [
"delivery"
],
"price": "$$",
"location": {
"address1": "3142 Colima Rd",
"address2": "",
"address3": "",
"city": "Hacienda Heights",
"zip_code": "91745",
"country": "US",
"state": "CA",
"display_address": [
"3142 Colima Rd",
"Hacienda Heights, CA 91745"
]
},
"phone": "+16269684794",
"display_phone": "(626) 968-4794",
"distance": 2271.295381028884
},
{
"id": "ovq2Sfpw7cQZbSMIqs07vg",
"alias": "hacienda-heights-pizza-company-hacienda-heights",
"name": "Hacienda Heights Pizza Company",
"image_url": "https://s3-media4.fl.yelpcdn.com/bphoto/codEYU-DR_GdRd7dsNsWyA/o.jpg",
"is_closed": false,
"url": "https://www.yelp.com/biz/hacienda-heights-pizza-company-hacienda-heights?adjust_creative=WpoQHLnOMdOyEndsLlwSPg&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=WpoQHLnOMdOyEndsLlwSPg",
"review_count": 437,
"categories": [
{
"alias": "pizza",
"title": "Pizza"
}
],
"rating": 3.5,
"coordinates": {
"latitude": 34.015013,
"longitude": -117.973866
},
"transactions": [
"pickup",
"delivery"
],
"price": "$$",
"location": {
"address1": "15239 Gale Ave",
"address2": "",
"address3": "",
"city": "Hacienda Heights",
"zip_code": "91745",
"country": "US",
"state": "CA",
"display_address": [
"15239 Gale Ave",
"Hacienda Heights, CA 91745"
]
},
"phone": "+16268552590",
"display_phone": "(626) 855-2590",
"distance": 1980.1106887021883
},
{
"id": "I92UQKaJKq9iaa4HTz2tXg",
"alias": "scardinos-pizza-to-go-la-puente",
"name": "Scardino's Pizza To Go",
"image_url": "https://s3-media3.fl.yelpcdn.com/bphoto/wE2Jm3DK-4bO_11xsXxGEQ/o.jpg",
"is_closed": false,
"url": "https://www.yelp.com/biz/scardinos-pizza-to-go-la-puente?adjust_creative=WpoQHLnOMdOyEndsLlwSPg&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=WpoQHLnOMdOyEndsLlwSPg",
"review_count": 339,
"categories": [
{
"alias": "pizza",
"title": "Pizza"
},
{
"alias": "italian",
"title": "Italian"
}
],
"rating": 4.5,
"coordinates": {
"latitude": 34.0496506030785,
"longitude": -117.946955922661
},
"transactions": [
"delivery"
],
"price": "$$",
"location": {
"address1": "1627 N Hacienda Blvd",
"address2": "",
"address3": "",
"city": "La Puente",
"zip_code": "91744",
"country": "US",
"state": "CA",
"display_address": [
"1627 N Hacienda Blvd",
"La Puente, CA 91744"
]
},
"phone": "+16269181507",
"display_phone": "(626) 918-1507",
"distance": 6552.790234543938
},
{
"id": "XzW26Or2ITIbkoTh2XME4w",
"alias": "fuoco-pizzeria-napoletana-fullerton",
"name": "Fuoco Pizzeria Napoletana",
"image_url": "https://s3-media4.fl.yelpcdn.com/bphoto/wE95ltg-16GPwYJf4Aof0w/o.jpg",
"is_closed": false,
"url": "https://www.yelp.com/biz/fuoco-pizzeria-napoletana-fullerton?adjust_creative=WpoQHLnOMdOyEndsLlwSPg&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=WpoQHLnOMdOyEndsLlwSPg",
"review_count": 1783,
"categories": [
{
"alias": "pizza",
"title": "Pizza"
},
{
"alias": "italian",
"title": "Italian"
},
{
"alias": "salad",
"title": "Salad"
}
],
"rating": 4.5,
"coordinates": {
"latitude": 33.87060085641833,
"longitude": -117.92457732489875
},
"transactions": [
"delivery"
],
"price": "$$",
"location": {
"address1": "101 N Harbor Blvd",
"address2": "",
"address3": "",
"city": "Fullerton",
"zip_code": "92832",
"country": "US",
"state": "CA",
"display_address": [
"101 N Harbor Blvd",
"Fullerton, CA 92832"
]
},
"phone": "+17146260727",
"display_phone": "(714) 626-0727",
"distance": 15285.200290883491
},
{
"id": "hTf8c43zQ7TFq6PHQAI2bw",
"alias": "love-letter-pizza-and-chicken-rowland-heights",
"name": "Love Letter Pizza & Chicken",
"image_url": "https://s3-media3.fl.yelpcdn.com/bphoto/zPQEFl8tgsXomodGvgvPMQ/o.jpg",
"is_closed": false,
"url": "https://www.yelp.com/biz/love-letter-pizza-and-chicken-rowland-heights?adjust_creative=WpoQHLnOMdOyEndsLlwSPg&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=WpoQHLnOMdOyEndsLlwSPg",
"review_count": 990,
"categories": [
{
"alias": "korean",
"title": "Korean"
},
{
"alias": "pizza",
"title": "Pizza"
},
{
"alias": "chicken_wings",
"title": "Chicken Wings"
}
],
"rating": 4,
"coordinates": {
"latitude": 33.989243,
"longitude": -117.904673
},
"transactions": [
"pickup",
"delivery"
],
"price": "$$",
"location": {
"address1": "18333B Colima Rd",
"address2": "",
"address3": "",
"city": "Rowland Heights",
"zip_code": "91748",
"country": "US",
"state": "CA",
"display_address": [
"18333B Colima Rd",
"Rowland Heights, CA 91748"
]
},
"phone": "+16268391235",
"display_phone": "(626) 839-1235",
"distance": 7344.37662932068
},
{
"id": "-5GSm4vuDDdtMaEPjPKwcQ",
"alias": "vinnys-italian-restaurant-la-habra-2",
"name": "Vinny's Italian Restaurant",
"image_url": "https://s3-media4.fl.yelpcdn.com/bphoto/x7mpbYWdKfoY465wY41wsQ/o.jpg",
"is_closed": false,
"url": "https://www.yelp.com/biz/vinnys-italian-restaurant-la-habra-2?adjust_creative=WpoQHLnOMdOyEndsLlwSPg&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=WpoQHLnOMdOyEndsLlwSPg",
"review_count": 1090,
"categories": [
{
"alias": "italian",
"title": "Italian"
},
{
"alias": "pizza",
"title": "Pizza"
}
],
"rating": 4.5,
"coordinates": {
"latitude": 33.92514,
"longitude": -117.92276
},
"transactions": [
"delivery"
],
"price": "$$",
"location": {
"address1": "2101 E Lambert Rd",
"address2": "",
"address3": "",
"city": "La Habra",
"zip_code": "90631",
"country": "US",
"state": "CA",
"display_address": [
"2101 E Lambert Rd",
"La Habra, CA 90631"
]
},
"phone": "+15626943400",
"display_phone": "(562) 694-3400",
"distance": 9950.263973452404
},
{
"id": "_FuGSE3AYx9nOTkODPut1g",
"alias": "la-crosta-wood-fired-pizza-whittier",
"name": "La Crosta Wood Fired Pizza",
"image_url": "https://s3-media4.fl.yelpcdn.com/bphoto/vdBfsfjDqDnxap0BwSLtdQ/o.jpg",
"is_closed": false,
"url": "https://www.yelp.com/biz/la-crosta-wood-fired-pizza-whittier?adjust_creative=WpoQHLnOMdOyEndsLlwSPg&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=WpoQHLnOMdOyEndsLlwSPg",
"review_count": 59,
"categories": [
{
"alias": "pizza",
"title": "Pizza"
}
],
"rating": 4.5,
"coordinates": {
"latitude": 33.9787781,
"longitude": -118.0370427
},
"transactions": [
"pickup",
"delivery"
],
"location": {
"address1": "13002 Philadelphia St",
"address2": "",
"address3": null,
"city": "Whittier",
"zip_code": "90601",
"country": "US",
"state": "CA",
"display_address": [
"13002 Philadelphia St",
"Whittier, CA 90601"
]
},
"phone": "+15623247577",
"display_phone": "(562) 324-7577",
"distance": 5430.611951758044
},
{
"id": "5bjEj57xtVg59fsIjWGCzQ",
"alias": "blackjack-pizzeria-la-habra",
"name": "Blackjack Pizzeria",
"image_url": "https://s3-media3.fl.yelpcdn.com/bphoto/5uQoPZ5RDa_uFS8tnioUSg/o.jpg",
"is_closed": false,
"url": "https://www.yelp.com/biz/blackjack-pizzeria-la-habra?adjust_creative=WpoQHLnOMdOyEndsLlwSPg&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=WpoQHLnOMdOyEndsLlwSPg",
"review_count": 429,
"categories": [
{
"alias": "pizza",
"title": "Pizza"
}
],
"rating": 4.5,
"coordinates": {
"latitude": 33.9398719780954,
"longitude": -117.973393835127
},
"transactions": [
"pickup",
"delivery"
],
"price": "$",
"location": {
"address1": "2429 W Whittier Blvd",
"address2": "",
"address3": "",
"city": "La Habra",
"zip_code": "90631",
"country": "US",
"state": "CA",
"display_address": [
"2429 W Whittier Blvd",
"La Habra, CA 90631"
]
},
"phone": "+15626944111",
"display_phone": "(562) 694-4111",
"distance": 6649.561538223691
},
{
"id": "lCn-WpZORhjjuVeXiNt5hA",
"alias": "pizzamania-whittier",
"name": "Pizzamania",
"image_url": "https://s3-media3.fl.yelpcdn.com/bphoto/oikKRCcC4Kncp0BBlruVYg/o.jpg",
"is_closed": false,
"url": "https://www.yelp.com/biz/pizzamania-whittier?adjust_creative=WpoQHLnOMdOyEndsLlwSPg&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=WpoQHLnOMdOyEndsLlwSPg",
"review_count": 1027,
"categories": [
{
"alias": "pizza",
"title": "Pizza"
}
],
"rating": 4,
"coordinates": {
"latitude": 33.9378271,
"longitude": -118.0427549
},
"transactions": [
"delivery"
],
"price": "$$",
"location": {
"address1": "13547 Telegraph Rd",
"address2": "",
"address3": "",
"city": "Whittier",
"zip_code": "90605",
"country": "US",
"state": "CA",
"display_address": [
"13547 Telegraph Rd",
"Whittier, CA 90605"
]
},
"phone": "+15629448803",
"display_phone": "(562) 944-8803",
"distance": 8691.538482559992
},
{
"id": "4qcbUWK6PtT_EhE1CL00OQ",
"alias": "ravello-osteria-monterey-park",
"name": "Ravello Osteria",
"image_url": "https://s3-media2.fl.yelpcdn.com/bphoto/SL-IEVhRUfuFcz1aZzYEQg/o.jpg",
"is_closed": false,
"url": "https://www.yelp.com/biz/ravello-osteria-monterey-park?adjust_creative=WpoQHLnOMdOyEndsLlwSPg&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=WpoQHLnOMdOyEndsLlwSPg",
"review_count": 578,
"categories": [
{
"alias": "italian",
"title": "Italian"
},
{
"alias": "pastashops",
"title": "Pasta Shops"
},
{
"alias": "pizza",
"title": "Pizza"
}
],
"rating": 4,
"coordinates": {
"latitude": 34.036084111352146,
"longitude": -118.1307262
},
"transactions": [
"delivery"
],
"price": "$$",
"location": {
"address1": "2315 S Garfield Ave",
"address2": "",
"address3": "",
"city": "Monterey Park",
"zip_code": "91754",
"country": "US",
"state": "CA",
"display_address": [
"2315 S Garfield Ave",
"Monterey Park, CA 91754"
]
},
"phone": "+13237227600",
"display_phone": "(323) 722-7600",
"distance": 14181.449997149568
},
{
"id": "a9Oo2cUQXv4V7sNzlWiMNQ",
"alias": "pizza-21-whittier",
"name": "Pizza 21",
"image_url": "https://s3-media3.fl.yelpcdn.com/bphoto/r37IuAf-RTO9YlkTTtHKKQ/o.jpg",
"is_closed": false,
"url": "https://www.yelp.com/biz/pizza-21-whittier?adjust_creative=WpoQHLnOMdOyEndsLlwSPg&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=WpoQHLnOMdOyEndsLlwSPg",
"review_count": 220,
"categories": [
{
"alias": "pizza",
"title": "Pizza"
}
],
"rating": 5,
"coordinates": {
"latitude": 33.9718658905689,
"longitude": -118.07371439367
},
"transactions": [
"pickup",
"delivery"
],
"price": "$",
"location": {
"address1": "8017 Norwalk Blvd",
"address2": "",
"address3": null,
"city": "Whittier",
"zip_code": "90606",
"country": "US",
"state": "CA",
"display_address": [
"8017 Norwalk Blvd",
"Whittier, CA 90606"
]
},
"phone": "+15628013689",
"display_phone": "(562) 801-3689",
"distance": 8853.647033272864
},
{
"id": "LKPl3iThbC2CdbnPb53XRQ",
"alias": "the-curry-pizza-company-walnut-walnut-2",
"name": "The Curry Pizza Company - Walnut",
"image_url": "https://s3-media1.fl.yelpcdn.com/bphoto/WaC6AFze5NVW9OrL_uGJ7g/o.jpg",
"is_closed": false,
"url": "https://www.yelp.com/biz/the-curry-pizza-company-walnut-walnut-2?adjust_creative=WpoQHLnOMdOyEndsLlwSPg&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=WpoQHLnOMdOyEndsLlwSPg",
"review_count": 318,
"categories": [
{
"alias": "indpak",
"title": "Indian"
},
{
"alias": "pizza",
"title": "Pizza"
},
{
"alias": "chicken_wings",
"title": "Chicken Wings"
}
],
"rating": 4.5,
"coordinates": {
"latitude": 34.0111996,
"longitude": -117.859211
},
"transactions": [
"pickup",
"delivery"
],
"price": "$$",
"location": {
"address1": "376 S Lemon Ave",
"address2": "",
"address3": null,
"city": "Walnut",
"zip_code": "91789",
"country": "US",
"state": "CA",
"display_address": [
"376 S Lemon Ave",
"Walnut, CA 91789"
]
},
"phone": "+19099785065",
"display_phone": "(909) 978-5065",
"distance": 11533.359141110845
},
{
"id": "Wcg_6rnWc6tpktt33ous7Q",
"alias": "baby-bros-pizza-and-wings-south-el-monte",
"name": "Baby Bros Pizza & Wings",
"image_url": "https://s3-media2.fl.yelpcdn.com/bphoto/MZ115Qxa5HTZvCGLWxYw5w/o.jpg",
"is_closed": false,
"url": "https://www.yelp.com/biz/baby-bros-pizza-and-wings-south-el-monte?adjust_creative=WpoQHLnOMdOyEndsLlwSPg&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=WpoQHLnOMdOyEndsLlwSPg",
"review_count": 292,
"categories": [
{
"alias": "pizza",
"title": "Pizza"
},
{
"alias": "chicken_wings",
"title": "Chicken Wings"
},
{
"alias": "beerbar",
"title": "Beer Bar"
}
],
"rating": 4,
"coordinates": {
"latitude": 34.05211,
"longitude": -118.05398
},
"transactions": [
"pickup",
"delivery"
],
"price": "$$",
"location": {
"address1": "9847 Rush St",
"address2": null,
"address3": "",
"city": "South El Monte",
"zip_code": "91733",
"country": "US",
"state": "CA",
"display_address": [
"9847 Rush St",
"South El Monte, CA 91733"
]
},
"phone": "+16264482316",
"display_phone": "(626) 448-2316",
"distance": 8772.804450272562
},
{
"id": "2UJcwkqvDAKPX8ZeNbQeFQ",
"alias": "pizzarev-rowland-heights",
"name": "PizzaRev",
"image_url": "https://s3-media1.fl.yelpcdn.com/bphoto/PiDjlQH6Nw7u4q9TLhaGQg/o.jpg",
"is_closed": false,
"url": "https://www.yelp.com/biz/pizzarev-rowland-heights?adjust_creative=WpoQHLnOMdOyEndsLlwSPg&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=WpoQHLnOMdOyEndsLlwSPg",
"review_count": 397,
"categories": [
{
"alias": "pizza",
"title": "Pizza"
}
],
"rating": 4.5,
"coordinates": {
"latitude": 33.9901605,
"longitude": -117.9246713
},
"transactions": [
"pickup",
"delivery"
],
"price": "$$",
"location": {
"address1": "17490 Colima Rd",
"address2": "Ste D",
"address3": null,
"city": "Rowland Heights",
"zip_code": "91748",
"country": "US",
"state": "CA",
"display_address": [
"17490 Colima Rd",
"Ste D",
"Rowland Heights, CA 91748"
]
},
"phone": "+16268540006",
"display_phone": "(626) 854-0006",
"distance": 5511.128701794727
},
{
"id": "SiyyceCOoIuEqCfZEwN3Hg",
"alias": "pie-trap-pizza-covina",
"name": "Pie Trap Pizza",
"image_url": "https://s3-media3.fl.yelpcdn.com/bphoto/o8_i3RxRXkFDDRu3p9l08Q/o.jpg",
"is_closed": false,
"url": "https://www.yelp.com/biz/pie-trap-pizza-covina?adjust_creative=WpoQHLnOMdOyEndsLlwSPg&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=WpoQHLnOMdOyEndsLlwSPg",
"review_count": 20,
"categories": [
{
"alias": "pizza",
"title": "Pizza"
}
],
"rating": 4.5,
"coordinates": {
"latitude": 34.105086485939346,
"longitude": -117.87669418232004
},
"transactions": [
],
"location": {
"address1": "720 E Arrow Hwy",
"address2": "Ste A",
"address3": "",
"city": "Covina",
"zip_code": "91702",
"country": "US",
"state": "CA",
"display_address": [
"720 E Arrow Hwy",
"Ste A",
"Covina, CA 91702"
]
},
"phone": "+16265410051",
"display_phone": "(626) 541-0051",
"distance": 15352.567810724982
},
{
"id": "efqeidrFoFzqVH1TEmJHIg",
"alias": "new-york-pizzeria-walnut",
"name": "New York Pizzeria",
"image_url": "https://s3-media2.fl.yelpcdn.com/bphoto/36tqlCLWgOLgIaYasL19Qw/o.jpg",
"is_closed": false,
"url": "https://www.yelp.com/biz/new-york-pizzeria-walnut?adjust_creative=WpoQHLnOMdOyEndsLlwSPg&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=WpoQHLnOMdOyEndsLlwSPg",
"review_count": 246,
"categories": [
{
"alias": "pizza",
"title": "Pizza"
},
{
"alias": "beer_and_wine",
"title": "Beer, Wine & Spirits"
},
{
"alias": "sandwiches",
"title": "Sandwiches"
}
],
"rating": 4,
"coordinates": {
"latitude": 34.0190473,
"longitude": -117.8650573
},
"transactions": [
"delivery"
],
"price": "$",
"location": {
"address1": "364 N Lemon Ave",
"address2": "",
"address3": "",
"city": "Walnut",
"zip_code": "91789",
"country": "US",
"state": "CA",
"display_address": [
"364 N Lemon Ave",
"Walnut, CA 91789"
]
},
"phone": "+19095945000",
"display_phone": "(909) 594-5000",
"distance": 11138.41781108791
},
{
"id": "nG3lHSvq3m0fzFQTdHjUSw",
"alias": "tonys-pizza-whittier",
"name": "Tony's Pizza",
"image_url": "https://s3-media1.fl.yelpcdn.com/bphoto/lZ7c-viftcFik1Y06I8xJA/o.jpg",
"is_closed": false,
"url": "https://www.yelp.com/biz/tonys-pizza-whittier?adjust_creative=WpoQHLnOMdOyEndsLlwSPg&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=WpoQHLnOMdOyEndsLlwSPg",
"review_count": 518,
"categories": [
{
"alias": "pizza",
"title": "Pizza"
}
],
"rating": 4,
"coordinates": {
"latitude": 33.9422540037959,
"longitude": -117.995184817488
},
"transactions": [
"pickup",
"delivery"
],
"price": "$$",
"location": {
"address1": "15624 Whittwood Ln",
"address2": "",
"address3": "",
"city": "Whittier",
"zip_code": "90603",
"country": "US",
"state": "CA",
"display_address": [
"15624 Whittwood Ln",
"Whittier, CA 90603"
]
},
"phone": "+15629470500",
"display_phone": "(562) 947-0500",
"distance": 6411.01480512212
},
{
"id": "DOB_k_gkyijSLgyt-_zodQ",
"alias": "jo-peeps-ny-pizza-whittier-3",
"name": "Jo Peeps Ny Pizza",
"image_url": "https://s3-media2.fl.yelpcdn.com/bphoto/vX-ghkTzaweOhKEIvq5wzw/o.jpg",
"is_closed": false,
"url": "https://www.yelp.com/biz/jo-peeps-ny-pizza-whittier-3?adjust_creative=WpoQHLnOMdOyEndsLlwSPg&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=WpoQHLnOMdOyEndsLlwSPg",
"review_count": 193,
"categories": [
{
"alias": "pizza",
"title": "Pizza"
},
{
"alias": "salad",
"title": "Salad"
},
{
"alias": "sandwiches",
"title": "Sandwiches"
}
],
"rating": 4,
"coordinates": {
"latitude": 33.9535433,
"longitude": -118.0161173
},
"transactions": [
"delivery"
],
"price": "$",
"location": {
"address1": "14450 Whittier Blvd",
"address2": "",
"address3": "",
"city": "Whittier",
"zip_code": "90605",
"country": "US",
"state": "CA",
"display_address": [
"14450 Whittier Blvd",
"Whittier, CA 90605"
]
},
"phone": "+15629459691",
"display_phone": "(562) 945-9691",
"distance": 5891.520785405544
},
{
"id": "2z5o4QXHgDc6vQLqZYoI8w",
"alias": "pizza-n-brews-whittier-3",
"name": "Pizza-N-Brews",
"image_url": "https://s3-media2.fl.yelpcdn.com/bphoto/eowFStZQxkd0V4bPg5rigA/o.jpg",
"is_closed": false,
"url": "https://www.yelp.com/biz/pizza-n-brews-whittier-3?adjust_creative=WpoQHLnOMdOyEndsLlwSPg&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=WpoQHLnOMdOyEndsLlwSPg",
"review_count": 43,
"categories": [
{
"alias": "pizza",
"title": "Pizza"
},
{
"alias": "sandwiches",
"title": "Sandwiches"
},
{
"alias": "beerbar",
"title": "Beer Bar"
}
],
"rating": 4.5,
"coordinates": {
"latitude": 33.94714,
"longitude": -118.00047
},
"transactions": [
"pickup",
"delivery"
],
"price": "$$",
"location": {
"address1": "15309 Whittier Blvd",
"address2": null,
"address3": "",
"city": "Whittier",
"zip_code": "90603",
"country": "US",
"state": "CA",
"display_address": [
"15309 Whittier Blvd",
"Whittier, CA 90603"
]
},
"phone": "+15629056048",
"display_phone": "(562) 905-6048",
"distance": 5980.620672175974
},
{
"id": "TK-qu1WwApLzzhRvKn7Mfg",
"alias": "tonys-little-italy-pizza-placentia",
"name": "Tony's Little Italy Pizza",
"image_url": "https://s3-media4.fl.yelpcdn.com/bphoto/tF4DOUTxrpPSSOvJW3P1ZA/o.jpg",
"is_closed": false,
"url": "https://www.yelp.com/biz/tonys-little-italy-pizza-placentia?adjust_creative=WpoQHLnOMdOyEndsLlwSPg&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=WpoQHLnOMdOyEndsLlwSPg",
"review_count": 2170,
"categories": [
{
"alias": "pizza",
"title": "Pizza"
}
],
"rating": 4,
"coordinates": {
"latitude": 33.8955049585903,
"longitude": -117.872027337872
},
"transactions": [
],
"price": "$$",
"location": {
"address1": "1808 N Placentia Ave",
"address2": "Unit B",
"address3": "",
"city": "Placentia",
"zip_code": "92870",
"country": "US",
"state": "CA",
"display_address": [
"1808 N Placentia Ave",
"Unit B",
"Placentia, CA 92870"
]
},
"phone": "+17145282159",
"display_phone": "(714) 528-2159",
"distance": 15438.106560936967
}
],
"total": 1700,
"region": {
"center": {
"longitude": -117.9834738,
"latitude": 33.9990858
}
}
}
I have an API with the below JSON format:
{
"message": true,
"result": [
{
"category": "Device",
"total_count": 288,
"total_price": 1769005231,
"brands": [
{
"brand": "DD",
"total_count": 127,
"total_price": 815344231,
"models": [
{
"model": "A01 Core",
"total_count": 0,
"total_price": 31231,
"items": [
{
"systemCode": "2000010010001001001001001",
"sku": "TEST DD A01 Core (1GB 16GB 4G) VV",
"model": "A01 Core",
"seller": "DSA",
"color": "Black",
"guaranty": "AORD",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 0,
"price": 31231
},
{
"systemCode": "2000010010001001001001001",
"sku": "TEST DD A01 Core (1GB 16GB 4G) VV",
"model": "A01 Core",
"seller": "DSA",
"color": "Black",
"guaranty": "AORD",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 0,
"price": 1000000
}
]
},
{
"model": "A13",
"total_count": 12,
"total_price": 61237000,
"items": [
{
"systemCode": "2000010010007001001001002",
"sku": "TEST DD A13 (4GB 64GB 4G) VV",
"model": "A13",
"seller": "DSA",
"color": "Black",
"guaranty": "SSS",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 0,
"price": 4249000
}
]
},
{
"model": "A22 5G",
"total_count": 0,
"total_price": 5239000,
"items": [
{
"systemCode": "2000010010010004001016002",
"sku": "TEST DD A22 5G (4GB 128GB 5G) II",
"model": "A22 5G",
"seller": "DSA",
"color": "White",
"guaranty": "SSS",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 5147010,
"price": 5239000
},
{
"systemCode": "2000010010010007001003002",
"sku": "TEST DD A22 5G (4GB 128GB 5G) RX | DSA | SSS [Gray]",
"model": "A22 5G",
"seller": "DSA",
"color": "Gray",
"guaranty": "SSS",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 5398044,
"price": 5299000
},
{
"systemCode": "2000010010010007001016002",
"sku": "TEST DD A22 5G (4GB 128GB 5G) RX | DSA | SSS [White]",
"model": "A22 5G",
"seller": "DSA",
"color": "White",
"guaranty": "SSS",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 0,
"price": 5239000
}
]
},
{
"model": "A52",
"total_count": 0,
"total_price": 8299000,
"items": [
{
"systemCode": "2000010010014002001001002",
"sku": "TEST DD A52 (8GB 128GB 4G) II",
"model": "A52",
"seller": "DSA",
"color": "Black",
"guaranty": "SSS",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 0,
"price": 8299000
},
{
"systemCode": "2000010010014004001005002",
"sku": "TEST DD A52 (8GB 256GB 4G) II",
"model": "A52",
"seller": "DSA",
"color": "Blue",
"guaranty": "SSS",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 0,
"price": 9099000
}
]
},
{
"model": "A52s",
"total_count": 12,
"total_price": 152487000,
"items": [
{
"systemCode": "2000010010015002001008001",
"sku": "TEST DD A52s (8GB 128GB 5G) II",
"model": "A52s",
"seller": "DSA",
"color": "Mint",
"guaranty": "AORD",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 9701010,
"price": 10159000
},
{
"systemCode": "2000010010015004001001001",
"sku": "TEST DD A52s (8GB 256GB 5G) II",
"model": "A52s",
"seller": "DSA",
"color": "Black",
"guaranty": "AORD",
"stockId": "903",
"quantity": 7,
"reserve": 0,
"salable": 7,
"dailySales": 0,
"balancedAvg": 11681010,
"price": 11919000
},
{
"systemCode": "2000010010015004001016001",
"sku": "TEST DD A52s (8GB 256GB 5G) II",
"model": "A52s",
"seller": "DSA",
"color": "White",
"guaranty": "AORD",
"stockId": "903",
"quantity": 5,
"reserve": 0,
"salable": 5,
"dailySales": 0,
"balancedAvg": 11483010,
"price": 11779000
},
{
"systemCode": "2000010010015004001016002",
"sku": "TEST DD A52s (8GB 256GB 5G) II",
"model": "A52s",
"seller": "DSA",
"color": "White",
"guaranty": "SSS",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 0,
"price": 11599000
}
]
},
{
"model": "A53",
"total_count": 0,
"total_price": 11379000,
"items": [
{
"systemCode": "2000010010016004001001002",
"sku": "TEST DD A53 (8GB 256GB 5G) II",
"model": "A53",
"seller": "DSA",
"color": "Black",
"guaranty": "SSS",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 11797000,
"price": 11379000
},
{
"systemCode": "2000010010016004001005002",
"sku": "TEST DD A53 (8GB 256GB 5G) II",
"model": "A53",
"seller": "DSA",
"color": "Blue",
"guaranty": "SSS",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 11855425,
"price": 11349000
}
]
},
{
"model": "A03",
"total_count": 0,
"total_price": 3099000,
"items": [
{
"systemCode": "2000010010003007001001001",
"sku": "TEST DD A03 (3GB 32GB 4G) RX",
"model": "A03",
"seller": "DSA",
"color": "Black",
"guaranty": "AORD",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 0,
"price": 3099000
}
]
}
]
},
{
"brand": "red",
"total_count": 28,
"total_price": 230893000,
"models": [
{
"model": "Ride 3 Pro 5G",
"total_count": 0,
"total_price": 5189000,
"items": [
{
"systemCode": "2000010050005003001030002",
"sku": "TEST Ride 3 Pro 5G (6GB 128GB 5G) Global",
"model": "Ride 3 Pro 5G",
"seller": "DSA",
"color": "Power Black",
"guaranty": "SSS",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 5088000,
"price": 5189000
}
]
},
{
"model": "Ride 4 Pro ",
"total_count": 0,
"total_price": 6769000,
"items": [
{
"systemCode": "2000010050006002001030002",
"sku": "TEST Ride 4 Pro (8GB 256GB 4G) Global",
"model": "Ride 4 Pro ",
"seller": "DSA",
"color": "Power Black",
"guaranty": "SSS",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 0,
"price": 6769000
},
{
"systemCode": "2000010050006002001032002",
"sku": "TEST Ride 4 Pro (8GB 256GB 4G) Global",
"model": "Ride 4 Pro ",
"seller": "DSA",
"color": "Cool Blue",
"guaranty": "SSS",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 0,
"price": 6759000
}
]
},
{
"model": "Ride 4 Pro 5G",
"total_count": 0,
"total_price": 5759000,
"items": [
{
"systemCode": "2000010050007001001030002",
"sku": "TEST Ride 4 Pro 5G (6GB 128GB 5G) Global",
"model": "Ride 4 Pro 5G",
"seller": "DSA",
"color": "Power Black",
"guaranty": "SSS",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 0,
"price": 5759000
}
]
},
{
"model": "red F3",
"total_count": 2,
"total_price": 10875000,
"items": [
{
"systemCode": "2000010050010002001102002",
"sku": "TEST red F3 (8GB 256GB 5G) Global | DSA | SSS [Arctic White]",
"model": "red F3",
"seller": "DSA",
"color": "Arctic White",
"guaranty": "SSS",
"stockId": "903",
"quantity": 2,
"reserve": 0,
"salable": 2,
"dailySales": 0,
"balancedAvg": 10450000,
"price": 10875000
}
]
},
{
"model": "red C31",
"total_count": 1,
"total_price": 3359000,
"items": [
{
"systemCode": "2000010050001004001043002",
"sku": "TEST red C31 (4GB 64GB 4G) II | DSA | SSS [Shadow Gray]",
"model": "red C31",
"seller": "DSA",
"color": "Shadow Gray",
"guaranty": "SSS",
"stockId": "903",
"quantity": 1,
"reserve": 0,
"salable": 1,
"dailySales": 0,
"balancedAvg": 3299000,
"price": 3359000
}
]
}
]
}
]
}
]
}
I want to transform this JSON to JOLT and import the result to a Mysql Table. The table has the below columns:
Brand ,Model ,total_count_model ,systemcode ,sku ,seller
How can i convert the JSON file to a Jolttransformjson?
I also use Jolt Transformation DSL and tried some JOLT specification.
Thank you
You can walk through indexes of the innermost array(namely items) within a shift transformation spec such as
[
{
"operation": "shift",
"spec": {
"*": {
"*": {
"brands": {
"*": {
"models": {
"*": {
"items": {
"*": {
"#(4,brand)": "[&5].[&3].&1.brand",
"#(2,model)": "[&5].[&3].&1.model",
"#(2,total_count)": "[&5].[&3].&1.total_count",
"model": "[&5].[&3].&1.items_model",
"systemCode": "[&5].[&3].&1.systemCode",
"sku": "[&5].[&3].&1.sku",
"seller": "[&5].[&3].&1.seller"
}
}
}
}
}
}
}
}
}
},
{
// get rid of the object labels
"operation": "shift",
"spec": {
"*": {
"*": {
"*": ""
}
}
}
}
]
I am trying to search for flights between two places in Sabre using BargainFindermax API. The API provides me with a list of all flights. However, there is no direct relation to which of the flights are linked.
For example, I searched for flights between BLR > LCY. The response I got included flights for AMS > LCY, BLR > DEL, BLR > DEL, DEL > AMS, AMS > LCY.
From this, I can construct the following route BLR > DEL > AMS > LCY. But there are two flights for BLR > DEL and AMS > LCY.
How can I identify which of these flights are related?
Here is the complete JSON response,
{
"groupedItineraryResponse": {
"version": "5.2.0",
"messages": [
{
"severity": "Info",
"type": "WORKERTHREAD",
"code": "TRANSACTIONID",
"text": "2074398531853061390"
},
{
"severity": "Info",
"type": "SERVER",
"code": "ASE032LPSCIL9UM.IDM.SGDCCERT.SABRE.COM",
"text": "27036"
},
{
"severity": "Info",
"type": "DRE",
"code": "RULEID",
"text": "17203"
},
{
"severity": "Info",
"type": "DEFAULT",
"code": "RULEID",
"text": "25238"
}
],
"statistics": {
"itineraryCount": 2
},
"scheduleDescs": [
{
"id": 1,
"frequency": "*MTWTFS",
"stopCount": 0,
"eTicketable": true,
"totalMilesFlown": 257,
"departure": {
"airport": "AMS",
"city": "AMS",
"country": "NL",
"time": "08:45:00+02:00"
},
"arrival": {
"airport": "LCY",
"city": "LON",
"country": "GB",
"time": "08:50:00+01:00"
},
"carrier": {
"marketing": "KL",
"marketingFlightNumber": 985,
"operating": "KL",
"operatingFlightNumber": 985,
"codeShared": "/KLM CITYHOPPER",
"equipment": {
"code": "E90",
"typeForFirstLeg": "N",
"typeForLastLeg": "N"
}
}
},
{
"id": 2,
"trafficRestriction": "G",
"frequency": "SMTWTFS",
"stopCount": 0,
"eTicketable": true,
"totalMilesFlown": 1058,
"departure": {
"airport": "BLR",
"city": "BLR",
"country": "IN",
"time": "19:50:00+05:30"
},
"arrival": {
"airport": "DEL",
"city": "DEL",
"country": "IN",
"time": "22:50:00+05:30",
"terminal": "3"
},
"carrier": {
"marketing": "KL",
"marketingFlightNumber": 3798,
"operating": "9W",
"operatingFlightNumber": 812,
"disclosure": "9W",
"equipment": {
"code": "73H",
"typeForFirstLeg": "N",
"typeForLastLeg": "N"
}
}
},
{
"id": 3,
"trafficRestriction": "G",
"frequency": "SMTWTFS",
"stopCount": 0,
"eTicketable": true,
"totalMilesFlown": 1058,
"departure": {
"airport": "BLR",
"city": "BLR",
"country": "IN",
"time": "18:55:00+05:30"
},
"arrival": {
"airport": "DEL",
"city": "DEL",
"country": "IN",
"time": "22:00:00+05:30",
"terminal": "3"
},
"carrier": {
"marketing": "KL",
"marketingFlightNumber": 3703,
"operating": "9W",
"operatingFlightNumber": 833,
"disclosure": "9W",
"equipment": {
"code": "738",
"typeForFirstLeg": "N",
"typeForLastLeg": "N"
}
}
},
{
"id": 4,
"frequency": "*M**T**",
"stopCount": 0,
"eTicketable": true,
"totalMilesFlown": 3961,
"departure": {
"airport": "DEL",
"city": "DEL",
"country": "IN",
"time": "02:10:00+05:30",
"terminal": "3"
},
"arrival": {
"airport": "AMS",
"city": "AMS",
"country": "NL",
"time": "07:40:00+02:00"
},
"carrier": {
"marketing": "KL",
"marketingFlightNumber": 3817,
"operating": "9W",
"operatingFlightNumber": 234,
"disclosure": "9W",
"equipment": {
"code": "333",
"typeForFirstLeg": "W",
"typeForLastLeg": "W"
}
}
},
{
"id": 5,
"frequency": "*MTWTFS",
"stopCount": 0,
"eTicketable": true,
"totalMilesFlown": 257,
"departure": {
"airport": "AMS",
"city": "AMS",
"country": "NL",
"time": "09:25:00+02:00"
},
"arrival": {
"airport": "LCY",
"city": "LON",
"country": "GB",
"time": "09:30:00+01:00"
},
"carrier": {
"marketing": "KL",
"marketingFlightNumber": 987,
"operating": "KL",
"operatingFlightNumber": 987,
"codeShared": "/KLM CITYHOPPER",
"equipment": {
"code": "E90",
"typeForFirstLeg": "N",
"typeForLastLeg": "N"
}
}
}
],
"taxDescs": [
{
"id": 1,
"code": "YRI",
"amount": 160,
"currency": "USD",
"description": "SERVICE FEE - CARRIER-IMPOSED MISC",
"publishedAmount": 160,
"publishedCurrency": "USD",
"station": "DEL"
},
{
"id": 2,
"code": "YQI",
"amount": 13.3,
"currency": "USD",
"description": "SERVICE FEE - INSURANCE",
"publishedAmount": 925,
"publishedCurrency": "INR",
"station": "BLR"
},
{
"id": 3,
"code": "WO",
"amount": 3.8,
"currency": "USD",
"description": "PASSENGER SERVICE FEE",
"publishedAmount": 3.8,
"publishedCurrency": "USD",
"station": "BLR",
"country": "IN"
},
{
"id": 4,
"code": "K38",
"amount": 11.5,
"currency": "USD",
"description": "GOODS AND SERVICE TAX INTERIM DOMESTIC AND INTERNATIONAL",
"publishedAmount": 799,
"publishedCurrency": "INR",
"station": "BLR",
"country": "IN"
},
{
"id": 5,
"code": "CJ",
"amount": 7.4,
"currency": "USD",
"description": "SECURITY SERVICE CHARGE",
"publishedAmount": 6.5,
"publishedCurrency": "EUR",
"station": "AMS",
"country": "NL"
},
{
"id": 6,
"code": "RN",
"amount": 7.3,
"currency": "USD",
"description": "PASSENGER SERVICE CHARGE",
"publishedAmount": 6.4,
"publishedCurrency": "EUR",
"station": "AMS",
"country": "NL"
},
{
"id": 7,
"code": "IN",
"amount": 5.2,
"currency": "USD",
"description": "USER DEVELOPMENT FEE DEPARTURES",
"publishedAmount": 362,
"publishedCurrency": "INR",
"station": "BLR",
"country": "IN"
}
],
"taxSummaryDescs": [
{
"id": 1,
"code": "YRI",
"amount": 160,
"currency": "USD",
"description": "SERVICE FEE - CARRIER-IMPOSED MISC",
"publishedAmount": 160,
"publishedCurrency": "USD",
"station": "DEL"
},
{
"id": 2,
"code": "YQI",
"amount": 13.3,
"currency": "USD",
"description": "SERVICE FEE - INSURANCE",
"publishedAmount": 925,
"publishedCurrency": "INR",
"station": "BLR"
},
{
"id": 3,
"code": "WO",
"amount": 3.8,
"currency": "USD",
"description": "PASSENGER SERVICE FEE",
"publishedAmount": 3.8,
"publishedCurrency": "USD",
"station": "BLR",
"country": "IN"
},
{
"id": 4,
"code": "K38",
"amount": 11.5,
"currency": "USD",
"description": "GOODS AND SERVICE TAX INTERIM DOMESTIC AND INTERNATIONAL",
"publishedAmount": 0.05,
"publishedCurrency": "INR",
"station": "BLR",
"country": "IN"
},
{
"id": 5,
"code": "CJ",
"amount": 7.4,
"currency": "USD",
"description": "SECURITY SERVICE CHARGE",
"publishedAmount": 6.5,
"publishedCurrency": "EUR",
"station": "AMS",
"country": "NL"
},
{
"id": 6,
"code": "RN",
"amount": 7.3,
"currency": "USD",
"description": "PASSENGER SERVICE CHARGE",
"publishedAmount": 6.4,
"publishedCurrency": "EUR",
"station": "AMS",
"country": "NL"
},
{
"id": 7,
"code": "IN",
"amount": 5.2,
"currency": "USD",
"description": "USER DEVELOPMENT FEE DEPARTURES",
"publishedAmount": 362,
"publishedCurrency": "INR",
"station": "BLR",
"country": "IN"
}
],
"fareComponentDescs": [
{
"id": 1,
"governingCarrier": "KL",
"fareAmount": 24.65,
"fareCurrency": "INR",
"fareBasisCode": "XPLWIA",
"farePassengerType": "ADT",
"publishedFareAmount": 1717,
"oneWayFare": true,
"directionality": "FROM",
"direction": "EH",
"notValidBefore": "2019-07-21",
"notValidAfter": "2019-07-21",
"applicablePricingCategories": "4 5 6 7 8 10 12 16 18",
"vendorCode": "ATP",
"fareTypeBitmap": "00",
"fareType": "PRU",
"fareTariff": "4",
"fareRule": "INPL",
"segments": [
{
"segment": {
"surcharges": [
{
"amount": 28.71,
"currency": "NUC",
"description": "MISCELLANEOUS/OTHER",
"type": "Q"
}
]
}
},
{
"segment": {}
},
{
"segment": {}
}
]
}
],
"validatingCarrierDescs": [
{
"id": 1,
"settlementMethod": "ARC",
"newVcxProcess": true,
"default": {
"code": "DL"
}
}
],
"baggageAllowanceDescs": [
{
"id": 1,
"pieceCount": 1
}
],
"legDescs": [
{
"id": 1,
"schedules": [
{
"ref": 2
},
{
"ref": 4,
"departureDateAdjustment": 1
},
{
"ref": 5,
"departureDateAdjustment": 1
}
]
},
{
"id": 2,
"schedules": [
{
"ref": 3
},
{
"ref": 4,
"departureDateAdjustment": 1
},
{
"ref": 1,
"departureDateAdjustment": 1
}
]
}
],
"itineraryGroups": [
{
"groupDescription": {
"legDescriptions": [
{
"departureDate": "2019-07-21",
"departureLocation": "BLR",
"arrivalLocation": "LCY"
}
]
},
"itineraries": [
{
"id": 1,
"pricingSource": "ADVJR1",
"legs": [
{
"ref": 2
}
],
"pricingInformation": [
{
"pricingSubsource": "MIP",
"fare": {
"validatingCarrierCode": "DL",
"vita": true,
"eTicketable": true,
"lastTicketDate": "2019-07-05",
"governingCarriers": "KL",
"passengerInfoList": [
{
"passengerInfo": {
"passengerType": "ADT",
"passengerNumber": 1,
"nonRefundable": true,
"fareComponents": [
{
"ref": 1,
"segments": [
{
"segment": {
"bookingCode": "X",
"cabinCode": "Y",
"mealCode": "D",
"seatsAvailable": 9
}
},
{
"segment": {
"bookingCode": "X",
"cabinCode": "Y",
"mealCode": "RB",
"seatsAvailable": 9
}
},
{
"segment": {
"bookingCode": "L",
"cabinCode": "Y",
"mealCode": "M",
"seatsAvailable": 9,
"availabilityBreak": true
}
}
]
}
],
"taxes": [
{
"ref": 2
},
{
"ref": 1
},
{
"ref": 7
},
{
"ref": 4
},
{
"ref": 3
},
{
"ref": 5
},
{
"ref": 6
}
],
"taxSummaries": [
{
"ref": 2
},
{
"ref": 1
},
{
"ref": 3
},
{
"ref": 4
},
{
"ref": 7
},
{
"ref": 5
},
{
"ref": 6
}
],
"currencyConversion": {
"from": "INR",
"to": "USD",
"exchangeRateUsed": 0.01442679
},
"fareMessages": [
{
"type": "N",
"code": "0",
"carrier": "KL",
"info": "FARE RESTRICTIONS APPLY/CARRIER RESTRICTIONS APPLY"
},
{
"type": "W",
"code": "0",
"info": "VALIDATING CARRIER - DL PER GSA AGREEMENT WITH KL"
}
],
"passengerTotalFare": {
"totalFare": 264.5,
"totalTaxAmount": 208.5,
"currency": "USD",
"baseFareAmount": 3875,
"baseFareCurrency": "INR",
"equivalentAmount": 56,
"equivalentCurrency": "USD",
"constructionAmount": 55.59,
"constructionCurrency": "NUC",
"commissionPercentage": 0,
"commissionAmount": 0,
"exchangeRateOne": 69.651352
},
"baggageInformation": [
{
"provisionType": "A",
"airlineCode": "KL",
"segments": [
{
"id": 0
},
{
"id": 1
},
{
"id": 2
}
],
"allowance": {
"ref": 1
}
}
]
}
}
],
"totalFare": {
"totalPrice": 264.5,
"totalTaxAmount": 208.5,
"currency": "USD",
"baseFareAmount": 3875,
"baseFareCurrency": "INR",
"constructionAmount": 55.59,
"constructionCurrency": "NUC",
"equivalentAmount": 56,
"equivalentCurrency": "USD"
},
"validatingCarriers": [
{
"ref": 1
}
]
}
}
],
"diversitySwapper": {
"weighedPrice": 409.855
}
},
{
"id": 2,
"pricingSource": "ADVJR1",
"legs": [
{
"ref": 1
}
],
"pricingInformation": [
{
"pricingSubsource": "MIP",
"fare": {
"validatingCarrierCode": "DL",
"vita": true,
"eTicketable": true,
"lastTicketDate": "2019-07-05",
"governingCarriers": "KL",
"passengerInfoList": [
{
"passengerInfo": {
"passengerType": "ADT",
"passengerNumber": 1,
"nonRefundable": true,
"fareComponents": [
{
"ref": 1,
"segments": [
{
"segment": {
"bookingCode": "X",
"cabinCode": "Y",
"mealCode": "D",
"seatsAvailable": 9
}
},
{
"segment": {
"bookingCode": "X",
"cabinCode": "Y",
"mealCode": "RB",
"seatsAvailable": 9
}
},
{
"segment": {
"bookingCode": "L",
"cabinCode": "Y",
"mealCode": "M",
"seatsAvailable": 9,
"availabilityBreak": true
}
}
]
}
],
"taxes": [
{
"ref": 2
},
{
"ref": 1
},
{
"ref": 7
},
{
"ref": 4
},
{
"ref": 3
},
{
"ref": 5
},
{
"ref": 6
}
],
"taxSummaries": [
{
"ref": 2
},
{
"ref": 1
},
{
"ref": 3
},
{
"ref": 4
},
{
"ref": 7
},
{
"ref": 5
},
{
"ref": 6
}
],
"currencyConversion": {
"from": "INR",
"to": "USD",
"exchangeRateUsed": 0.01442679
},
"fareMessages": [
{
"type": "N",
"code": "0",
"carrier": "KL",
"info": "FARE RESTRICTIONS APPLY/CARRIER RESTRICTIONS APPLY"
},
{
"type": "W",
"code": "0",
"info": "VALIDATING CARRIER - DL PER GSA AGREEMENT WITH KL"
}
],
"passengerTotalFare": {
"totalFare": 264.5,
"totalTaxAmount": 208.5,
"currency": "USD",
"baseFareAmount": 3875,
"baseFareCurrency": "INR",
"equivalentAmount": 56,
"equivalentCurrency": "USD",
"constructionAmount": 55.59,
"constructionCurrency": "NUC",
"commissionPercentage": 0,
"commissionAmount": 0,
"exchangeRateOne": 69.651352
},
"baggageInformation": [
{
"provisionType": "A",
"airlineCode": "KL",
"segments": [
{
"id": 0
},
{
"id": 1
},
{
"id": 2
}
],
"allowance": {
"ref": 1
}
}
]
}
}
],
"totalFare": {
"totalPrice": 264.5,
"totalTaxAmount": 208.5,
"currency": "USD",
"baseFareAmount": 3875,
"baseFareCurrency": "INR",
"constructionAmount": 55.59,
"constructionCurrency": "NUC",
"equivalentAmount": 56,
"equivalentCurrency": "USD"
},
"validatingCarriers": [
{
"ref": 1
}
]
}
}
],
"diversitySwapper": {
"weighedPrice": 367.631
}
}
]
}
]
}
}
You have to use legDescs list to connect your segments, and use those "ref" values.
For example:
{
"id": 2,
"schedules": [
{
"ref": 3
},
{
"departureDateAdjustment": 1,
"ref": 4
},
{
"departureDateAdjustment": 1,
"ref": 1
}
]
}
means, your flight with ID = 2 contains 3 segments, with id 3 - 4 and 1. When you search numbered segments in "scheduleDescs" object, you can see routes are:
BLR - DEL
DEL - AMS
AMS - LCY
and as you can see you got the BLR - LCY flight.
I use jq 1.5 under a Windows enviroment to modify a given large json file to extract a single Array ("Offers") from that large file:
'.Offers[] | ({Price: .AdultPriceEUR, Currency: .Currency, Link: .Deeplink, Tickettyp: .TicketClassIndex, Flightindex: .FlightIndex })'
After that i got an "unnamed" Array. But for the later processing it is necessary that the Array keeps his old "Name". I checked the documentation and found the setpath function but it is not possible to keep the Name "easy" on extraction?
shorten example of the json file:
{"Airports": [
{
"Aliases": null,
"ContinentCode": "EU",
"ContinentGroup": 1,
"CountryCode": "DE",
"CountryName": "Germany",
"DST": "",
"DisplayName": "Hamburg (HAM) Germany",
"Iata": "HAM",
"IataLink": false,
"Icao": "EDDH",
"Latitude": 53.63215,
"Longitude": 10.0041609,
"MainCityCode": "HAM",
"MainCityDisplayName": "Hamburg (HAM) Germany",
"MainCityName": "Hamburg",
"Name": "Hamburg",
"Priority": 142,
"StateCode": null,
"StateName": null,
"TimeZone": -798214753
},
{
"Aliases": null,
"ContinentCode": "AS",
"ContinentGroup": 4,
"CountryCode": "TH",
"CountryName": "Thailand",
"DST": "",
"DisplayName": "Suvarnabhumi, Bangkok (BKK) Thailand",
"Iata": "BKK",
"IataLink": false,
"Icao": "VTBS",
"Latitude": 13.6922979,
"Longitude": 100.750694,
"MainCityCode": "BKK",
"MainCityDisplayName": "Bangkok (BKK) Thailand",
"MainCityName": "Bangkok",
"Name": "Suvarnabhumi",
"Priority": 1462,
"StateCode": null,
"StateName": null,
"TimeZone": -640089798
}], "Offers": [
{
"AdultPrice": 2977.6,
"AdultPriceEUR": 2977.6,
"AdultPriceExclTax": 0.0,
"Currency": "EUR",
"FeeIndexes": [
0,
1,
2,
3,
4,
5,
6
],
"FlightIndex": 0,
"IsPaymentIncluded": true,
"MobileDeepLink": null,
"PaymentMethods": [
"American Express",
"Diners Club",
"MasterCard Credit",
"MasterCard Debit",
"Paypal",
"Visa Credit",
"Visa Debit"
],
"Score": 2501.3,
"SegmentFares": null,
"SegmentKey": -1,
"TicketClassIndex": 1,
"TotalIsCalculated": false,
"TotalPrice": 2977.6,
"TotalPriceEUR": 2977.6,
"TotalPriceExclTax": 0.0
},
{
"AdultPrice": 4697.27,
"AdultPriceEUR": 4697.27,
"AdultPriceExclTax": 0.0,
"Currency": "EUR",
"FeeIndexes": [
0,
1,
2,
3,
4,
7,
8,
5,
6
],
"FlightIndex": 1,
"IsPaymentIncluded": true,
"MobileDeepLink": null,
"PaymentMethods": [
"American Express",
"Diners Club",
"MasterCard Credit",
"MasterCard Debit",
"Paypal",
"Sofortüberweisung",
"Überweisung",
"Visa Credit",
"Visa Debit"
],
"Score": 3438.64,
"SegmentFares": null,
"SegmentKey": -1,
"TicketClassIndex": 1,
"TotalIsCalculated": false,
"TotalPrice": 4697.27,
"TotalPriceEUR": 4697.27,
"TotalPriceExclTax": 0.0
}]
}
thanks
BR
Timo
Looks like you're looking at this:
jq '{Offers:[.Offers[] | {Price: .AdultPriceEUR, Currency: .Currency, Link: .Deeplink, Tickettyp: .TicketClassIndex, Flightindex: .FlightIndex }]}' file
It just creates a new object containing an Offers table with the content you want to put it it.
I'm new in Ionic development. I'm having a problem retrieving JSON.
"Failed to load https://api.wh.geniussports.com/v1/basketball/competitions/19816/matcheslive?ak=eebd8ae256142ac3fd24bd2003d28782: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access."
Here's my json format
{
"response": {
"meta": {
"version": 1,
"code": 200,
"status": "success",
"request": "http://api.wh.geniussports.com/v1/basketball/competitions/19816/matcheslive?ak=eebd8ae256142ac3fd24bd2003d28782",
"time": 1528177532,
"count": 10,
"limit": 10
},
"data": [
{
"leagueId": 6,
"matchId": 784470,
"competitionId": 19816,
"venueId": 17386,
"poolNumber": 0,
"roundNumber": "1",
"roundDescription": "",
"matchNumber": 1,
"matchStatus": "COMPLETE",
"matchName": "",
"phaseName": "",
"extraPeriodsUsed": 0,
"matchTime": "2017-11-17 19:30:00",
"matchTimeUTC": "2017-11-17 11:30:00",
"enddate": null,
"timeActual": "2017-11-17 19:45:37",
"timeEndActual": "2017-11-17 21:12:10",
"durationActual": 87,
"temperature": 0,
"attendance": 0,
"duration": 120,
"weather": "",
"twitterHashtag": "",
"liveStream": 1,
"matchType": "REGULAR",
"keywords": "",
"ticketURL": "",
"externalId": "920",
"nextMatchId": 0,
"placeIfWon": 0,
"placeIfLost": 0,
"updated": "2017-11-24 11:04:00",
"linkDetail": "/v1/basketball/matches/784470",
"linkDetailLeague": "/v1/basketball/leagues/6",
"venue": {
"venueId": 17386,
"venueName": "Nanhai Gymnasium",
"venueNameInternational": "",
"venueNickname": "Nanhai Gym",
"venueNicknameInternational": "",
"surfaceName": "",
"locationName": "",
"website": "",
"ticketURL": "",
"externalId": "54",
"linkDetailVenue": "/v1/basketball/venues/17386"
},
"leagueName": "ASEAN Basketball League",
"leagueNameInternational": "",
"competitionName": "2017 ASEAN Basketball League",
"competitionNameInternational": "",
"gsId": "",
"competitors": [
{
"competitorType": "TEAM",
"competitorName": "Singapore Slingers",
"competitorId": 88261,
"linkDetailCompetitor": "/v1/basketball/teams/88261",
"scoreString": "59",
"scoreSecondaryString": "",
"completionStatus": "COMPLETE",
"resultPlacing": 0,
"isDrawn": 0,
"isHomeCompetitor": 0,
"teamId": 88261,
"teamName": "Singapore Slingers",
"teamGsId": null,
"teamNameInternational": "",
"teamNickname": "Singapore Slingers",
"teamNicknameInternational": "",
"teamCode": "",
"teamCodeInternational": "",
"website": "",
"internationalReference": "",
"externalId": "74",
"images": {
"logo": {
"L1": {
"size": "L1",
"height": 600,
"width": 600,
"bytes": 45196,
"url": "http://img.wh.sportingpulseinternational.com/5b71cf0a1af51c8376eda43e6ba5bc22L1.jpg"
},
"M1": {
"size": "M1",
"height": 400,
"width": 400,
"bytes": 25005,
"url": "http://img.wh.sportingpulseinternational.com/5b71cf0a1af51c8376eda43e6ba5bc22M1.jpg"
},
"S1": {
"size": "S1",
"height": 200,
"width": 200,
"bytes": 9180,
"url": "http://img.wh.sportingpulseinternational.com/5b71cf0a1af51c8376eda43e6ba5bc22S1.jpg"
},
"T1": {
"size": "T1",
"height": 75,
"width": 75,
"bytes": 2270,
"url": "http://img.wh.sportingpulseinternational.com/5b71cf0a1af51c8376eda43e6ba5bc22T1.jpg"
}
}
},
"clubId": 62,
"clubGsId": null,
"clubName": "Singapore Slingers",
"clubNameInternational": "",
"linkDetailClub": "/v1/basketball/clubs/62"
},
Below is my loadUser function
loadUser(){
this.http.get('http://api.wh.geniussports.com/v1/basketball/competitions/19816/matcheslive?ak=eebd8ae256142ac3fd24bd2003d28782')
.map(res => res.json())
.subscribe(res => {
this.data = data.results;
console.log(data.results);
}, err => {
console.log(err);
});
}
My main goal is to log the data[] array. Please help me
This is the problem with browser, typically its a security concern not to allow other requests which may lead to XSS attack easily. If only for development I suggest you to install a plugin which will disable in your browser plugin
If for production, then you need to configure your API then do this .