Unexpected end of JSON input when using fs.watch() and require() NodeJS - json

When checking for a new file inside my ./Assetto1/results folder (.json file) the code should read the new file (result = require("[...]")) and log it into console. But I'm always getting the same error. Even trying for 8 hours now. The same thing happens, when using fs.readFile() instead of require(). I even tried an npm module called "decache" so that I could somehow "derequire" the file. My idea was that nodejs then expects the end of the JSON file. But nothing of this helps, as well.
Take a look at my code i wrote:
var fs = require("fs");
fs.watch('./Assetto1/results/', (eventType, filename) => {
console.log("EventType:"+eventType);
if (eventType == "rename") {
console.log("Debug: Rename");
console.log("./Assetto1/results/"+filename);
result = require("./Assetto1/results/"+filename);
console.log(result);
}
})
Console Output looks like this:
SyntaxError: /home/Assetto1/results/2018_9_8_9_0_RACE.json: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at Object.Module._extensions..json (internal/modules/cjs/loader.js:708:27)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:20:18)
at FSWatcher.fs.watch (/home/main.js:59:12)
at FSWatcher.emit (events.js:182:13)
at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:130:12)
Content of the JSON file (AssettoCorsa Race-Results):
{
"TrackName": "spa",
"TrackConfig": "",
"Type": "RACE",
"DurationSecs": 0,
"RaceLaps": 5,
"Cars": [
{
"CarId": 0,
"Driver": {
"Name": "NoaH",
"Team": "",
"Nation": "DEU",
"Guid": "76561198190801825",
"GuidsList": [
""
]
},
"Model": "mercedes_sls_gt3",
"Skin": "Black_Falcon_SB_Mobel_Boss_10",
"BallastKG": 0,
"Restrictor": 0
},
{
"CarId": 1,
"Driver": {
"Name": "",
"Team": "",
"Nation": "",
"Guid": "",
"GuidsList": [
""
]
},
"Model": "mercedes_sls_gt3",
"Skin": "Black_Falcon_Porta_9",
"BallastKG": 0,
"Restrictor": 0
},
{
"CarId": 2,
"Driver": {
"Name": "",
"Team": "",
"Nation": "",
"Guid": "",
"GuidsList": [
""
]
},
"Model": "mercedes_sls_gt3",
"Skin": "Kunos_zp_115",
"BallastKG": 0,
"Restrictor": 0
},
{
"CarId": 3,
"Driver": {
"Name": "",
"Team": "",
"Nation": "",
"Guid": "",
"GuidsList": [
""
]
},
"Model": "mercedes_sls_gt3",
"Skin": "Kunos_zp_116",
"BallastKG": 0,
"Restrictor": 0
},
{
"CarId": 4,
"Driver": {
"Name": "",
"Team": "",
"Nation": "",
"Guid": "",
"GuidsList": [
""
]
},
"Model": "mercedes_sls_gt3",
"Skin": "Black_Falcon_Dubai_24H_2",
"BallastKG": 0,
"Restrictor": 0
},
{
"CarId": 5,
"Driver": {
"Name": "",
"Team": "",
"Nation": "",
"Guid": "",
"GuidsList": [
""
]
},
"Model": "mercedes_sls_gt3",
"Skin": "Black_Falcon_SB_Mobel_Boss_10",
"BallastKG": 0,
"Restrictor": 0
},
{
"CarId": 6,
"Driver": {
"Name": "",
"Team": "",
"Nation": "",
"Guid": "",
"GuidsList": [
""
]
},
"Model": "mercedes_sls_gt3",
"Skin": "Black_Falcon_Porta_9",
"BallastKG": 0,
"Restrictor": 0
},
{
"CarId": 7,
"Driver": {
"Name": "",
"Team": "",
"Nation": "",
"Guid": "",
"GuidsList": [
""
]
},
"Model": "mercedes_sls_gt3",
"Skin": "Kunos_zp_115",
"BallastKG": 0,
"Restrictor": 0
},
{
"CarId": 8,
"Driver": {
"Name": "",
"Team": "",
"Nation": "",
"Guid": "",
"GuidsList": [
""
]
},
"Model": "mercedes_sls_gt3",
"Skin": "Kunos_zp_116",
"BallastKG": 0,
"Restrictor": 0
},
{
"CarId": 9,
"Driver": {
"Name": "",
"Team": "",
"Nation": "",
"Guid": "",
"GuidsList": [
""
]
},
"Model": "mercedes_sls_gt3",
"Skin": "Black_Falcon_Dubai_24H_2",
"BallastKG": 0,
"Restrictor": 0
},
{
"CarId": 10,
"Driver": {
"Name": "Ian Loncar",
"Team": "",
"Nation": "HRV",
"Guid": "76561198273369988",
"GuidsList": [
""
]
},
"Model": "ks_nissan_gtr",
"Skin": "solid_red",
"BallastKG": 0,
"Restrictor": 0
},
{
"CarId": 11,
"Driver": {
"Name": "",
"Team": "",
"Nation": "",
"Guid": "",
"GuidsList": [
""
]
},
"Model": "ks_nissan_gtr",
"Skin": "jet_black",
"BallastKG": 0,
"Restrictor": 0
},
{
"CarId": 12,
"Driver": {
"Name": "",
"Team": "",
"Nation": "",
"Guid": "",
"GuidsList": [
""
]
},
"Model": "ks_nissan_gtr",
"Skin": "0_pearl_white",
"BallastKG": 0,
"Restrictor": 0
},
{
"CarId": 13,
"Driver": {
"Name": "",
"Team": "",
"Nation": "",
"Guid": "",
"GuidsList": [
""
]
},
"Model": "ks_nissan_gtr",
"Skin": "super_silver",
"BallastKG": 0,
"Restrictor": 0
},
{
"CarId": 14,
"Driver": {
"Name": "",
"Team": "",
"Nation": "",
"Guid": "",
"GuidsList": [
""
]
},
"Model": "ks_nissan_gtr",
"Skin": "jet_black",
"BallastKG": 0,
"Restrictor": 0
},
{
"CarId": 15,
"Driver": {
"Name": "F. Riestra.ESP.",
"Team": "",
"Nation": "",
"Guid": "76561198130349639",
"GuidsList": [
""
]
},
"Model": "ks_audi_r8_plus",
"Skin": "10_sepang_blue_pearl",
"BallastKG": 0,
"Restrictor": 0
},
{
"CarId": 16,
"Driver": {
"Name": "",
"Team": "",
"Nation": "",
"Guid": "",
"GuidsList": [
""
]
},
"Model": "ks_audi_r8_plus",
"Skin": "11_suzuka_gray_metallic_t",
"BallastKG": 0,
"Restrictor": 0
},
{
"CarId": 17,
"Driver": {
"Name": "",
"Team": "",
"Nation": "",
"Guid": "",
"GuidsList": [
""
]
},
"Model": "ks_audi_r8_plus",
"Skin": "09_samoa_orange_metallic_t",
"BallastKG": 0,
"Restrictor": 0
},
{
"CarId": 18,
"Driver": {
"Name": "",
"Team": "",
"Nation": "",
"Guid": "",
"GuidsList": [
""
]
},
"Model": "ks_audi_r8_plus",
"Skin": "Brilliant_Red",
"BallastKG": 0,
"Restrictor": 0
},
{
"CarId": 19,
"Driver": {
"Name": "sale7almanna3i",
"Team": "",
"Nation": "QAT",
"Guid": "76561198139068257",
"GuidsList": [
""
]
},
"Model": "ks_lamborghini_huracan_performante",
"Skin": "blu_cepheus",
"BallastKG": 0,
"Restrictor": 0
},
{
"CarId": 20,
"Driver": {
"Name": "raafaal1661",
"Team": "",
"Nation": "",
"Guid": "76561198857669454",
"GuidsList": [
""
]
},
"Model": "ks_lamborghini_huracan_performante",
"Skin": "giallo_horus",
"BallastKG": 0,
"Restrictor": 0
},
{
"CarId": 21,
"Driver": {
"Name": "alexpavillanueva",
"Team": "",
"Nation": "ESP",
"Guid": "76561198834760853",
"GuidsList": [
""
]
},
"Model": "ks_lamborghini_huracan_performante",
"Skin": "blu_nethuns",
"BallastKG": 0,
"Restrictor": 0
},
{
"CarId": 22,
"Driver": {
"Name": "NoaH",
"Team": "",
"Nation": "DEU",
"Guid": "76561198190801825",
"GuidsList": [
""
]
},
"Model": "ks_lamborghini_huracan_performante",
"Skin": "00_arancio_anthaeus",
"BallastKG": 0,
"Restrictor": 0
},
{
"CarId": 23,
"Driver": {
"Name": "",
"Team": "",
"Nation": "",
"Guid": "",
"GuidsList": [
""
]
},
"Model": "ks_lamborghini_huracan_performante",
"Skin": "rosso_efesto",
"BallastKG": 0,
"Restrictor": 0
}
],
"Result": [
{
"DriverName": "NoaH",
"DriverGuid": "76561198190801825",
"CarId": 22,
"CarModel": "ks_lamborghini_huracan_performante",
"BestLap": 174182,
"TotalTime": 891017,
"BallastKG": 0,
"Restrictor": 0
},
{
"DriverName": "NoaH",
"DriverGuid": "76561198190801825",
"CarId": 0,
"CarModel": "mercedes_sls_gt3",
"BestLap": 999999999,
"TotalTime": 0,
"BallastKG": 0,
"Restrictor": 0
},
{
"DriverName": "",
"DriverGuid": "",
"CarId": 2,
"CarModel": "mercedes_sls_gt3",
"BestLap": 999999999,
"TotalTime": 0,
"BallastKG": 0,
"Restrictor": 0
},
{
"DriverName": "",
"DriverGuid": "",
"CarId": 3,
"CarModel": "mercedes_sls_gt3",
"BestLap": 999999999,
"TotalTime": 0,
"BallastKG": 0,
"Restrictor": 0
},
{
"DriverName": "",
"DriverGuid": "",
"CarId": 4,
"CarModel": "mercedes_sls_gt3",
"BestLap": 999999999,
"TotalTime": 0,
"BallastKG": 0,
"Restrictor": 0
},
{
"DriverName": "",
"DriverGuid": "",
"CarId": 5,
"CarModel": "mercedes_sls_gt3",
"BestLap": 999999999,
"TotalTime": 0,
"BallastKG": 0,
"Restrictor": 0
},
{
"DriverName": "",
"DriverGuid": "",
"CarId": 6,
"CarModel": "mercedes_sls_gt3",
"BestLap": 999999999,
"TotalTime": 0,
"BallastKG": 0,
"Restrictor": 0
},
{
"DriverName": "",
"DriverGuid": "",
"CarId": 7,
"CarModel": "mercedes_sls_gt3",
"BestLap": 999999999,
"TotalTime": 0,
"BallastKG": 0,
"Restrictor": 0
},
{
"DriverName": "",
"DriverGuid": "",
"CarId": 8,
"CarModel": "mercedes_sls_gt3",
"BestLap": 999999999,
"TotalTime": 0,
"BallastKG": 0,
"Restrictor": 0
},
{
"DriverName": "",
"DriverGuid": "",
"CarId": 9,
"CarModel": "mercedes_sls_gt3",
"BestLap": 999999999,
"TotalTime": 0,
"BallastKG": 0,
"Restrictor": 0
},
{
"DriverName": "Ian Loncar",
"DriverGuid": "76561198273369988",
"CarId": 10,
"CarModel": "ks_nissan_gtr",
"BestLap": 999999999,
"TotalTime": 0,
"BallastKG": 0,
"Restrictor": 0
},
{
"DriverName": "",
"DriverGuid": "",
"CarId": 11,
"CarModel": "ks_nissan_gtr",
"BestLap": 999999999,
"TotalTime": 0,
"BallastKG": 0,
"Restrictor": 0
},
{
"DriverName": "",
"DriverGuid": "",
"CarId": 12,
"CarModel": "ks_nissan_gtr",
"BestLap": 999999999,
"TotalTime": 0,
"BallastKG": 0,
"Restrictor": 0
},
{
"DriverName": "",
"DriverGuid": "",
"CarId": 13,
"CarModel": "ks_nissan_gtr",
"BestLap": 999999999,
"TotalTime": 0,
"BallastKG": 0,
"Restrictor": 0
},
{
"DriverName": "",
"DriverGuid": "",
"CarId": 14,
"CarModel": "ks_nissan_gtr",
"BestLap": 999999999,
"TotalTime": 0,
"BallastKG": 0,
"Restrictor": 0
},
{
"DriverName": "F. Riestra.ESP.",
"DriverGuid": "76561198130349639",
"CarId": 15,
"CarModel": "ks_audi_r8_plus",
"BestLap": 999999999,
"TotalTime": 0,
"BallastKG": 0,
"Restrictor": 0
},
{
"DriverName": "",
"DriverGuid": "",
"CarId": 16,
"CarModel": "ks_audi_r8_plus",
"BestLap": 999999999,
"TotalTime": 0,
"BallastKG": 0,
"Restrictor": 0
},
{
"DriverName": "",
"DriverGuid": "",
"CarId": 17,
"CarModel": "ks_audi_r8_plus",
"BestLap": 999999999,
"TotalTime": 0,
"BallastKG": 0,
"Restrictor": 0
},
{
"DriverName": "",
"DriverGuid": "",
"CarId": 18,
"CarModel": "ks_audi_r8_plus",
"BestLap": 999999999,
"TotalTime": 0,
"BallastKG": 0,
"Restrictor": 0
},
{
"DriverName": "sale7almanna3i",
"DriverGuid": "76561198139068257",
"CarId": 19,
"CarModel": "ks_lamborghini_huracan_performante",
"BestLap": 999999999,
"TotalTime": 0,
"BallastKG": 0,
"Restrictor": 0
},
{
"DriverName": "raafaal1661",
"DriverGuid": "76561198857669454",
"CarId": 20,
"CarModel": "ks_lamborghini_huracan_performante",
"BestLap": 999999999,
"TotalTime": 0,
"BallastKG": 0,
"Restrictor": 0
},
{
"DriverName": "alexpavillanueva",
"DriverGuid": "76561198834760853",
"CarId": 21,
"CarModel": "ks_lamborghini_huracan_performante",
"BestLap": 999999999,
"TotalTime": 0,
"BallastKG": 0,
"Restrictor": 0
},
{
"DriverName": "",
"DriverGuid": "",
"CarId": 1,
"CarModel": "mercedes_sls_gt3",
"BestLap": 999999999,
"TotalTime": 0,
"BallastKG": 0,
"Restrictor": 0
},
{
"DriverName": "",
"DriverGuid": "",
"CarId": 23,
"CarModel": "ks_lamborghini_huracan_performante",
"BestLap": 999999999,
"TotalTime": 0,
"BallastKG": 0,
"Restrictor": 0
}
],
"Laps": [
{
"DriverName": "NoaH",
"DriverGuid": "76561198190801825",
"CarId": 22,
"CarModel": "ks_lamborghini_huracan_performante",
"Timestamp": 35470691,
"LapTime": 180196,
"Sectors": [
50515,
82440,
47241
],
"Cuts": 0,
"BallastKG": 0,
"Tyre": "HR",
"Restrictor": 0
},
{
"DriverName": "NoaH",
"DriverGuid": "76561198190801825",
"CarId": 22,
"CarModel": "ks_lamborghini_huracan_performante",
"Timestamp": 35645934,
"LapTime": 175240,
"Sectors": [
48331,
82125,
44784
],
"Cuts": 0,
"BallastKG": 0,
"Tyre": "HR",
"Restrictor": 0
},
{
"DriverName": "NoaH",
"DriverGuid": "76561198190801825",
"CarId": 22,
"CarModel": "ks_lamborghini_huracan_performante",
"Timestamp": 35824671,
"LapTime": 178746,
"Sectors": [
46162,
85482,
47102
],
"Cuts": 0,
"BallastKG": 0,
"Tyre": "HR",
"Restrictor": 0
},
{
"DriverName": "NoaH",
"DriverGuid": "76561198190801825",
"CarId": 22,
"CarModel": "ks_lamborghini_huracan_performante",
"Timestamp": 36007357,
"LapTime": 182686,
"Sectors": [
46340,
85492,
50854
],
"Cuts": 0,
"BallastKG": 0,
"Tyre": "HR",
"Restrictor": 0
},
{
"DriverName": "NoaH",
"DriverGuid": "76561198190801825",
"CarId": 22,
"CarModel": "ks_lamborghini_huracan_performante",
"Timestamp": 36181518,
"LapTime": 174182,
"Sectors": [
46693,
81995,
45494
],
"Cuts": 0,
"BallastKG": 0,
"Tyre": "HR",
"Restrictor": 0
}
],
"Events": [
{
"Type": "COLLISION_WITH_ENV",
"CarId": 22,
"Driver": {
"Name": "NoaH",
"Team": "",
"Nation": "DEU",
"Guid": "76561198190801825",
"GuidsList": [
""
]
},
"OtherCarId": -1,
"OtherDriver": {
"Name": "",
"Team": "",
"Nation": "",
"Guid": "",
"GuidsList": null
},
"ImpactSpeed": 12.305487,
"WorldPosition": {
"X": 415.25763,
"Y": 38.005207,
"Z": 847.0971
},
"RelPosition": {
"X": -0.96855915,
"Y": 0.31426933,
"Z": -1.4876876
}
},
{
"Type": "COLLISION_WITH_ENV",
"CarId": 22,
"Driver": {
"Name": "NoaH",
"Team": "",
"Nation": "DEU",
"Guid": "76561198190801825",
"GuidsList": [
""
]
},
"OtherCarId": -1,
"OtherDriver": {
"Name": "",
"Team": "",
"Nation": "",
"Guid": "",
"GuidsList": null
},
"ImpactSpeed": 69.01873,
"WorldPosition": {
"X": -449.24142,
"Y": 30.581987,
"Z": -1006.0361
},
"RelPosition": {
"X": 0.68840855,
"Y": -0.285217,
"Z": 2.4184985
}
},
{
"Type": "COLLISION_WITH_ENV",
"CarId": 22,
"Driver": {
"Name": "NoaH",
"Team": "",
"Nation": "DEU",
"Guid": "76561198190801825",
"GuidsList": [
""
]
},
"OtherCarId": -1,
"OtherDriver": {
"Name": "",
"Team": "",
"Nation": "",
"Guid": "",
"GuidsList": null
},
"ImpactSpeed": 22.243214,
"WorldPosition": {
"X": 416.29285,
"Y": 37.574894,
"Z": 849.2622
},
"RelPosition": {
"X": -0.8986338,
"Y": -0.2784356,
"Z": 2.0484245
}
}
]
}
So now I don't really know what I can do against it.
Maybe you guys can help me,
thanks.

So guys, after reading your posts carefully, I got the idea that I just have to wait until the file is written completely. I've done that with a simple Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 1000); after that, I can read out the file without a single problem. So, that's the solution for everyone else who stumbles across this problem like me.
Thanks

How is the file created? You probably just have a race condition with the file being created (which triggers the fs.watch event and reading of the file), then the JSON is written after a bit of processing, but it's already too late. Or the JSON is big and it takes time to write it all.
Two options for you:
the process that creates the JSON should work in another directory (but on the same filesystem). Once the file is fully written out, move it to the directory. This way, you have an atomic change, and you know that when you receive the event the file is complete.
An alternative is to write in the same directory, but rename once finished, and have a convention for what files are temporary or final (e.g. if the file is .xxxx.tmp ignore the event).
or whenever you receive an event for a file (rename or change):
cancel any previously created timer for that file
create a new timer for that file
when the timer expires, actually read the file

Related

How do i transform a nested json to Jolt in Apache NIFI

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": {
"*": {
"*": {
"*": ""
}
}
}
}
]

Converting JSON data to model class Flutter

I want to convert JSON data to model class, I used this https://javiercbk.github.io/json_to_dart/ but I am not getting what I want, can you please assist.
My JSON data
[
{
"Id": 0,
"SourceId": 0,
"ServiceId": 11,
"CategoryId": 5,
"Category": "Valuation",
"Description": "AdjustedValues",
"Value": [],
"ServiceResponsePropertyId": 474,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13818024,
"SortOrder": 1
},
{
"Id": 0,
"SourceId": 0,
"ServiceId": 11,
"CategoryId": 1,
"Category": "General",
"Description": "ServiceStatus",
"Value": {
"StatusCode": 1,
"StatusDescription": "Ok",
"StatusDetail": "",
"RestServiceStatus": null,
"ServiceResource": null
},
"ServiceResponsePropertyId": 475,
"MappingId": 0,
"IsVisible": false,
"PackageRequestId": 13818024,
"SortOrder": 1
},
{
"Id": 0,
"SourceId": 0,
"ServiceId": 6,
"CategoryId": 1,
"Category": "General",
"Description": "CarId",
"Value": 120354,
"ServiceResponsePropertyId": 100,
"MappingId": 0,
"IsVisible": false,
"PackageRequestId": 13818024,
"SortOrder": 1
},
{
"Id": 0,
"SourceId": 0,
"ServiceId": 6,
"CategoryId": 1,
"Category": "General",
"Description": "Year",
"Value": 2017,
"ServiceResponsePropertyId": 103,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13818024,
"SortOrder": 6
},
{
"Id": 0,
"SourceId": 0,
"ServiceId": 6,
"CategoryId": 1,
"Category": "General",
"Description": "Full Model Description",
"Value": "2017 AUDI A3 Sedan 1.0T FSI S tronic [2016-2017]",
"ServiceResponsePropertyId": 104,
"MappingId": 0,
"IsVisible": false,
"PackageRequestId": 13818024,
"SortOrder": 1
},
{
"Id": 0,
"SourceId": 0,
"ServiceId": 6,
"CategoryId": 1,
"Category": "General",
"Description": "Model",
"Value": "A3 Sedan 1.0T FSI S tronic [2016-2017]",
"ServiceResponsePropertyId": 105,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13818024,
"SortOrder": 5
},
{
"Id": 0,
"SourceId": 0,
"ServiceId": 6,
"CategoryId": 1,
"Category": "General",
"Description": "ImageUrl",
"Value": "https://cdn.lightstoneauto.co.za/PHOTOS/AUDI/120354_1_Z7.jpg",
"ServiceResponsePropertyId": 107,
"MappingId": 0,
"IsVisible": false,
"PackageRequestId": 13818024,
"SortOrder": 1
},
{
"Id": 0,
"SourceId": 0,
"ServiceId": 6,
"CategoryId": 1,
"Category": "General",
"Description": "Make",
"Value": "AUDI",
"ServiceResponsePropertyId": 110,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13818024,
"SortOrder": 3
},
{
"Id": 0,
"SourceId": 0,
"ServiceId": 6,
"CategoryId": 1,
"Category": "General",
"Description": "Type",
"Value": "AUDI A3 Sedan",
"ServiceResponsePropertyId": 111,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13818024,
"SortOrder": 4
},
{
"Id": 0,
"SourceId": 0,
"ServiceId": 6,
"CategoryId": 1,
"Category": "General",
"Description": "ServiceStatus",
"Value": {
"StatusCode": 1,
"StatusDescription": "Ok",
"StatusDetail": "",
"RestServiceStatus": null,
"ServiceResource": null
},
"ServiceResponsePropertyId": 125,
"MappingId": 0,
"IsVisible": false,
"PackageRequestId": 13818024,
"SortOrder": 1
},
{
"Id": 0,
"SourceId": 0,
"ServiceId": 7,
"CategoryId": 1,
"Category": "General",
"Description": "ServiceStatus",
"Value": {
"StatusCode": 1,
"StatusDescription": "Ok",
"StatusDetail": "",
"RestServiceStatus": null,
"ServiceResource": null
},
"ServiceResponsePropertyId": 126,
"MappingId": 0,
"IsVisible": false,
"PackageRequestId": 13818024,
"SortOrder": 9999
},
{
"CarId": 0,
"SpecCategory": "General",
"Id": -1,
"SourceId": -1,
"ServiceId": 7,
"CategoryId": 1,
"Category": "General",
"Description": "Body shape",
"Value": "Sedan",
"ServiceResponsePropertyId": 320,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13818024,
"SortOrder": 9999
},
{
"CarId": 0,
"SpecCategory": "General",
"Id": -6,
"SourceId": -6,
"ServiceId": 7,
"CategoryId": 1,
"Category": "General",
"Description": "Drive type",
"Value": "4x2",
"ServiceResponsePropertyId": 154,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13818024,
"SortOrder": 9999
},
{
"CarId": 0,
"SpecCategory": "General",
"Id": -7,
"SourceId": -7,
"ServiceId": 7,
"CategoryId": 1,
"Category": "General",
"Description": "Fuel type",
"Value": "Petrol",
"ServiceResponsePropertyId": 153,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13818024,
"SortOrder": 9999
},
{
"Id": 0,
"SourceId": 0,
"ServiceId": 12,
"CategoryId": 5,
"Category": "Valuation",
"Description": "LastFiveSales",
"Value": [
{
"SaleId": 698229,
"CarId": 120354,
"SaleYear": 2017,
"SaleDateTime": "2022-06-09T15:30:38Z",
"SalePrice": 299900.0,
"MunicipalityName": "CITY OF TSHWANE",
"Id": 0,
"SourceId": 0,
"ServiceId": 0,
"CategoryId": 0,
"Category": null,
"Description": null,
"Value": null,
"ServiceResponsePropertyId": 0,
"MappingId": 1,
"IsVisible": false,
"PackageRequestId": 0,
"SortOrder": 0
},
{
"SaleId": 695530,
"CarId": 120354,
"SaleYear": 2017,
"SaleDateTime": "2022-05-30T13:24:17Z",
"SalePrice": 289995.0,
"MunicipalityName": "CITY OF TSHWANE",
"Id": 0,
"SourceId": 0,
"ServiceId": 0,
"CategoryId": 0,
"Category": null,
"Description": null,
"Value": null,
"ServiceResponsePropertyId": 0,
"MappingId": 1,
"IsVisible": false,
"PackageRequestId": 0,
"SortOrder": 0
},
{
"SaleId": 685020,
"CarId": 120354,
"SaleYear": 2017,
"SaleDateTime": "2022-04-14T12:27:37Z",
"SalePrice": 366948.0,
"MunicipalityName": "EMFULENI",
"Id": 0,
"SourceId": 0,
"ServiceId": 0,
"CategoryId": 0,
"Category": null,
"Description": null,
"Value": null,
"ServiceResponsePropertyId": 0,
"MappingId": 1,
"IsVisible": false,
"PackageRequestId": 0,
"SortOrder": 0
},
{
"SaleId": 683843,
"CarId": 120354,
"SaleYear": 2017,
"SaleDateTime": "2022-04-11T15:00:38Z",
"SalePrice": 315500.0,
"MunicipalityName": "UMHLATHUZE",
"Id": 0,
"SourceId": 0,
"ServiceId": 0,
"CategoryId": 0,
"Category": null,
"Description": null,
"Value": null,
"ServiceResponsePropertyId": 0,
"MappingId": 1,
"IsVisible": false,
"PackageRequestId": 0,
"SortOrder": 0
},
{
"SaleId": 652718,
"CarId": 120354,
"SaleYear": 2017,
"SaleDateTime": "2022-04-01T11:53:45Z",
"SalePrice": 339900.0,
"MunicipalityName": "CITY OF TSHWANE",
"Id": 0,
"SourceId": 0,
"ServiceId": 0,
"CategoryId": 0,
"Category": null,
"Description": null,
"Value": null,
"ServiceResponsePropertyId": 0,
"MappingId": 1,
"IsVisible": false,
"PackageRequestId": 0,
"SortOrder": 0
}
],
"ServiceResponsePropertyId": 481,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13818024,
"SortOrder": 0
},
{
"Id": 0,
"SourceId": 0,
"ServiceId": 12,
"CategoryId": 5,
"Category": "Valuation",
"Description": "ServiceStatus",
"Value": {
"StatusCode": 1,
"StatusDescription": "Ok",
"StatusDetail": "",
"RestServiceStatus": null,
"ServiceResource": null
},
"ServiceResponsePropertyId": 482,
"MappingId": 0,
"IsVisible": false,
"PackageRequestId": 13818024,
"SortOrder": 0
},
{
"EstimateType": "Auction",
"CarId": 0,
"Id": 1,
"SourceId": 1,
"ServiceId": 12,
"CategoryId": 5,
"Category": "Valuation",
"Description": "Auction Estimate",
"Value": 189400.0,
"ServiceResponsePropertyId": 494,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13818024,
"SortOrder": 1
},
{
"EstimateType": "Cost",
"CarId": 0,
"Id": 2,
"SourceId": 2,
"ServiceId": 12,
"CategoryId": 5,
"Category": "Valuation",
"Description": "Cost Estimate",
"Value": 238300.0,
"ServiceResponsePropertyId": 495,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13818024,
"SortOrder": 1
},
{
"EstimateType": "Cost",
"CarId": 0,
"Id": 3,
"SourceId": 3,
"ServiceId": 12,
"CategoryId": 5,
"Category": "Valuation",
"Description": "Cost Estimate High",
"Value": 259800.0,
"ServiceResponsePropertyId": 496,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13818024,
"SortOrder": 3
},
{
"EstimateType": "Cost",
"CarId": 0,
"Id": 4,
"SourceId": 4,
"ServiceId": 12,
"CategoryId": 5,
"Category": "Valuation",
"Description": "Cost Estimate Low",
"Value": 218700.0,
"ServiceResponsePropertyId": 497,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13818024,
"SortOrder": 2
},
{
"EstimateType": "Retail",
"CarId": 0,
"Id": 5,
"SourceId": 5,
"ServiceId": 12,
"CategoryId": 5,
"Category": "Valuation",
"Description": "Retail Estimate",
"Value": 300800.0,
"ServiceResponsePropertyId": 498,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13818024,
"SortOrder": 1
},
{
"EstimateType": "Retail",
"CarId": 0,
"Id": 6,
"SourceId": 6,
"ServiceId": 12,
"CategoryId": 5,
"Category": "Valuation",
"Description": "Retail Estimate High",
"Value": 327900.0,
"ServiceResponsePropertyId": 499,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13818024,
"SortOrder": 3
},
{
"EstimateType": "Retail",
"CarId": 0,
"Id": 7,
"SourceId": 7,
"ServiceId": 12,
"CategoryId": 5,
"Category": "Valuation",
"Description": "Retail Estimate Low",
"Value": 276000.0,
"ServiceResponsePropertyId": 500,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13818024,
"SortOrder": 2
},
{
"EstimateType": "Trade",
"CarId": 0,
"Id": 8,
"SourceId": 8,
"ServiceId": 12,
"CategoryId": 5,
"Category": "Valuation",
"Description": "Trade Estimate",
"Value": 261300.0,
"ServiceResponsePropertyId": 501,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13818024,
"SortOrder": 1
},
{
"EstimateType": "Trade",
"CarId": 0,
"Id": 9,
"SourceId": 9,
"ServiceId": 12,
"CategoryId": 5,
"Category": "Valuation",
"Description": "Trade Estimate High",
"Value": 284900.0,
"ServiceResponsePropertyId": 502,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13818024,
"SortOrder": 3
},
{
"EstimateType": "Trade",
"CarId": 0,
"Id": 10,
"SourceId": 10,
"ServiceId": 12,
"CategoryId": 5,
"Category": "Valuation",
"Description": "Trade Estimate Low",
"Value": 239800.0,
"ServiceResponsePropertyId": 503,
"MappingId": 0,
"IsVisible": true,
"PackageRequestId": 13818024,
"SortOrder": 2
},
{
"Id": 0,
"SourceId": 0,
"ServiceId": 11,
"CategoryId": 7,
"Category": "Report",
"Description": "ReportUrl",
"Value": "https://pdf.lightstoneauto.co.za/Index.aspx?sourceurl=https://cdn.lightstoneauto.co.za/REPORTS/LIVE/ba22673b-0f05-4ae9-b212-0369a7c793ad.html",
"ServiceResponsePropertyId": 0,
"MappingId": 0,
"IsVisible": false,
"PackageRequestId": 0,
"SortOrder": 0
},
{
"Id": 0,
"SourceId": 0,
"ServiceId": 11,
"CategoryId": 7,
"Category": "Report",
"Description": "HtmlUrl",
"Value": "https://cdn.lightstoneauto.co.za/REPORTS/LIVE/ba22673b-0f05-4ae9-b212-0369a7c793ad.html",
"ServiceResponsePropertyId": 0,
"MappingId": 0,
"IsVisible": false,
"PackageRequestId": 0,
"SortOrder": 0
}
]
I want to show only type "Value" on the UI, so can anyone assist on how can I create the model class with this json data then show the "Value" on a list or text so can anyone please help on how do I go about this?? I have stuck for a while now. Your help will be appreciated, thanks in advance.
class DartClass {
int? id;
int? sourceId;
int? serviceId;
int? categoryId;
String? category;
String? description;
dynamic value;
int? serviceResponsePropertyId;
int? mappingId;
bool? isVisible;
int? packageRequestId;
int? sortOrder;
DartClass(
{this.id,
this.sourceId,
this.serviceId,
this.categoryId,
this.category,
this.description,
this.value,
this.serviceResponsePropertyId,
this.mappingId,
this.isVisible,
this.packageRequestId,
this.sortOrder});
DartClass.fromJson(Map<String, dynamic> json) {
id = json['Id'];
sourceId = json['SourceId'];
serviceId = json['ServiceId'];
categoryId = json['CategoryId'];
category = json['Category'];
description = json['Description'];
value = json['Value'];
serviceResponsePropertyId = json['ServiceResponsePropertyId'];
mappingId = json['MappingId'];
isVisible = json['IsVisible'];
packageRequestId = json['PackageRequestId'];
sortOrder = json['SortOrder'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = {};
data['Id'] = id;
data['SourceId'] = sourceId;
data['ServiceId'] = serviceId;
data['CategoryId'] = categoryId;
data['Category'] = category;
data['Description'] = description;
data['Value'] = value;
data['ServiceResponsePropertyId'] = serviceResponsePropertyId;
data['MappingId'] = mappingId;
data['IsVisible'] = isVisible;
data['PackageRequestId'] = packageRequestId;
data['SortOrder'] = sortOrder;
return data;
}
}

Zomato JSON Response

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);
}
});

Ionic Json nested

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 .

Cannot read JSON in pandas

I have a nested JSON. I want it to be read in pandas in order to explore it, but I got errors. When to use read_json method, I got: "Trailing data". It is valid JSON. How to read it in pd? (Tried differently, but did not work). It looks like this:
{
"contributors": null,
"coordinates": null,
"created_at": "Fri May 26 08:54:00 +0000 2017",
"entities": {
"hashtags": [],
"media": [
{
"display_url": "pic.twitter.com/Pm28ORTePl",
"expanded_url": "",
"id": 868027417121751040,
"id_str": "868027417121751040",
"indices": [
94,
117
],
"media_url": "",
"sizes": {
"large": {
"h": 404,
"resize": "fit",
"w": 773
},
"medium": {
"h": 404,
"resize": "fit",
"w": 773
},
"small": {
"h": 355,
"resize": "fit",
"w": 680
},
"thumb": {
"h": 150,
"resize": "crop",
"w": 150
}
},
"type": "photo",
"url": ""
}
],
"symbols": [],
"urls": [
{
"display_url": "",
"expanded_url": "",
"indices": [
70,
93
],
"url": ""
}
],
"user_mentions": []
},
"extended_entities": {
"media": [
{
"display_url": "pic.twitter.com/Pm28ORTePl",
"expanded_url": "1",
"id": 868027417121751040,
"id_str": "868027417121751040",
"indices": [
94,
117
],
"media_url": "",
"media_url_https": "",
"sizes": {
"large": {
"h": 404,
"resize": "fit",
"w": 773
},
"medium": {
"h": 404,
"resize": "fit",
"w": 773
},
"small": {
"h": 355,
"resize": "fit",
"w": 680
},
"thumb": {
"h": 150,
"resize": "crop",
"w": 150
}
},
"type": "photo",
"url": ""
}
]
},
"favorite_count": 1,
"favorited": false,
"geo": null,
"id": 868027425757724672,
"id_str": "868027425757724672",
"in_reply_to_screen_name": null,
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,
"in_reply_to_user_id": null,
"in_reply_to_user_id_str": null,
"is_quote_status": false,
"lang": "ru",
"place": null,
"possibly_sensitive": false,
"retweet_count": 0,
"retweeted": false,
"source": "Twitter Web Client",
"text": "\u041f\u0440\u043e\u043f\u0430\u0432\u0448\u0430\u044f \u0432 \u041a\u043e\u043a\u0448\u0435\u0442\u0430\u0443 \u0448\u043a\u043e\u043b\u044c\u043d\u0438\u0446\u0430 \u0436\u0438\u043b\u0430 \u0432 \u0437\u0430\u0431\u0440\u043e\u0448\u0435\u043d\u043d\u043e\u043c \u0434\u043e\u043c\u0435 \u0438 \u0431\u0440\u043e\u0434\u044f\u0436\u043d\u0438\u0447\u0430\u043b\u0430\n",
"truncated": false,
"user": {
"contributors_enabled": false,
"created_at": "Wed May 18 11:59:50 +0000 2011",
"default_profile": true,
"default_profile_image": false,
"description": "\u041a\u0430\u0437\u0430\u0445\u0441\u0442\u0430\u043d\u0441\u043a\u0438\u0439 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043f\u043e\u0440\u0442\u0430\u043b",
"entities": {
"description": {
"urls": []
},
"url": {
"urls": [
{
"display_url": "",
"expanded_url": "",
"indices": [
0,
22
],
"url": ""
}
]
}
},
"favourites_count": 87,
"follow_request_sent": false,
"followers_count": 17989,
"following": true,
"friends_count": 98,
"geo_enabled": true,
"has_extended_profile": false,
"id": 300811189,
"id_str": "300811189",
"is_translation_enabled": false,
"is_translator": false,
"lang": "ru",
"listed_count": 86,
"location": "\u0410\u043b\u043c\u0430\u0442\u044b",
"name": "",
"notifications": false,
"profile_background_color": "C0DEED",
"profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
"profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
"profile_background_tile": false,
"profile_banner_url": "https://pbs.twimg.com/profile_banners/300811189/1489117916",
"profile_image_url": "http://pbs.twimg.com/profile_images/840047424882298881/NxZSyfhM_normal.jpg",
"profile_image_url_https": "https://pbs.twimg.com/profile_images/840047424882298881/NxZSyfhM_normal.jpg",
"profile_link_color": "1DA1F2",
"profile_sidebar_border_color": "C0DEED",
"profile_sidebar_fill_color": "DDEEF6",
"profile_text_color": "333333",
"profile_use_background_image": true,
"protected": false,
"screen_name": "",
"statuses_count": 53011,
"time_zone": "Quito",
"translator_type": "none",
"url": "",
"utc_offset": -18000,
"verified": false
}
}
Sorry, but your JSON is actually not valid, despite your saying it is.
This line:
"media_url": "": "",
Should probably be:
"media_url": "",
At which point, when I added the final bracket } that was outside of your code block, validated as properly formed JSON.