Ionic Json nested - json

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 .

Related

json jq request format

I need help to extract data from this JSON file using jq.
The app flv then verify the streamname mystrame is active and extract meta.video.height
I did try lot of queries without success and my jq knowledge is poor.
{
"port": 1935,
"server_index": 0,
"applications": [{
"name": "hls",
"live": {
"streams": [{
"name": "donbosco",
"time": 2380739,
"bw_in": 2112440,
"bytes_in": 541618713,
"bw_out": 0,
"bytes_out": 0,
"bw_audio": 35544,
"bw_video": 2076888,
"clients": [{
"id": 453,
"address": "127.0.0.1",
"time": 2380959,
"flashver": "FMLE/3.0 (compatible; Lavf57.83.100)",
"dropped": 0,
"avsync": 28,
"timestamp": 2382635,
"publishing": true,
"active": true
}],
"records": [],
"meta": {
"video": {
"width": 1168,
"height": 720,
"frame_rate": 25,
"codec": "H264",
"profile": "High",
"level": 3.1
},
"audio": {
"codec": "AAC",
"profile": "LC",
"channels": 2,
"sample_rate": 16000
}
},
"nclients": 1,
"publishing": true,
"active": true
}],
"nclients": 1
},
"recorders": {
"count": 0,
"lists": []
}
},
{
"name": "flv",
"live": {
"streams": [{
"name": "mystream",
"time": 2382811,
"bw_in": 2059096,
"bytes_in": 541841549,
"bw_out": 2059096,
"bytes_out": 543351459,
"bw_audio": 35472,
"bw_video": 2023624,
"clients": [{
"id": 452,
"address": "127.0.0.1",
"time": 2382727,
"flashver": "LNX 9,0,124,2",
"dropped": 0,
"avsync": -12,
"timestamp": 2384520,
"publishing": false,
"active": true
},
{
"id": 451,
"address": "127.0.0.1",
"time": 2383031,
"flashver": "FMLE/3.0 (compatible; Lavf58.74.100)",
"dropped": 0,
"avsync": -12,
"timestamp": 2384520,
"publishing": true,
"active": true
}
],
"records": [],
"meta": {
"video": {
"width": 1168,
"height": 720,
"frame_rate": 25,
"codec": "H264",
"profile": "High",
"level": 3.1
},
"audio": {
"codec": "AAC",
"profile": "LC",
"channels": 2,
"sample_rate": 16000
}
},
"nclients": 2,
"publishing": true,
"active": true
}],
"nclients": 2
},
"recorders": {
"count": 0,
"lists": []
}
}
]
}
Are you asking for help with the command-line JSON processor jq or the JavaScript library jQuery? They are not the same. For jq, try
jq '
.applications
| map(select(.name == "flv"))[].live.streams
| map(select(.name == "mystream" and .active))[].meta.video.height
'
720
Demo

Error parsing a specific JSON file in Snowflake with File Format

I have created a Stage and File Format in Snowflake which works with all my other JSON files except this, which throws an error:
Error parsing JSON: misplaced { File 'rooms.json.gz', line 1,
character 2 Row 0, column $1
I am using the same query that I am using for other files.
SELECT $1
FROM #MySchema.MY_STAGE/rooms.json.gz
;
What is wrong with the structure of this specific JSON file?
{
"rooms": [
{
"area": 131.49,
"longDescription": "",
"dateCreated": 1589908063390,
"reservable": false,
"name": "E249",
"remoteInfo": "",
"description": "",
"id": 2,
"type": {
"hexColor": "c16058",
"contentFlag": 1,
"cost": 0.0,
"dateCreated": 1308610520717,
"color": {},
"name": "BREAK ROOM",
"occupiable": false,
"id": 120,
"parkingSpace": false,
"dateUpdated": 1591818585913,
"typeCode": ""
},
"floor": {
"area": 25312.9878,
"dateCreated": 1589907703870,
"drawingAvailable": true,
"interiorGross": 0.0,
"name": "2",
"leaseArea": 0.0,
"id": 12,
"building": {
"address": {
"country": {
"defaultSelected": true,
"subdivisionCategoryName": "state",
"alpha2Code": "US",
"isoCode": "US",
"name": "United States of America (the)",
"id": 223
},
"city": "Some City",
"street": "Some Drive",
"postalCode": "00000",
"state": {
"country": {
"defaultSelected": true,
"subdivisionCategoryName": "state",
"alpha2Code": "US",
"isoCode": "US",
"name": "United States of America (the)",
"id": 223
},
"defaultSelected": false,
"code": "XX",
"name": "Some State",
"id": 66,
"categoryName": "state"
}
},
"code": "B2",
"dateCreated": 1589907508020,
"metric": false,
"name": "Some name",
"location": {},
"revitLink": "",
"id": 45,
"dateUpdated": 1601315841453,
"costCenters": []
},
"dateUpdated": 1600441936663
},
"capacity": 0,
"dateUpdated": 1600441936960
}
]
}
Edit: Screenshot from Notepad++ with all characters enabled

Problem getting Image URL with Strapi / Nuxt

I am trying to get the image URL from a JSON which I get from a call to my strapi content. It is for an events website. Here is the code. When I console.log the image url, i get 'undefined'. However, all other properties of event show up no problem.
created() {
axios.get('http://localhost:1338/events').then(res => {
this.events = res.data.sort((a, b) => b.date < a.date ? 1: -1);
console.log(this.events[0].image.url)
})
.catch(err => console.log(err))
}
Console: undefined
Here is the JSON:
{
"id": 1,
"title": "Aphex Twin Live Set",
"description": "Risus viverra adipiscing at in tellus integer feugiat scelerisque varius.",
"date": "2020-12-23T16:00:00.000Z",
"price": 10,
"published_at": "2020-12-19T17:25:44.340Z",
"created_at": "2020-12-19T17:25:41.833Z",
"updated_at": "2020-12-19T21:42:15.696Z",
"image": [
{
"id": 1,
"name": "aphex.jpeg",
"alternativeText": "",
"caption": "",
"width": 1200,
"height": 630,
"formats": {
"thumbnail": {
"name": "thumbnail_aphex.jpeg",
"hash": "thumbnail_aphex_11b34d4058",
"ext": ".jpeg",
"mime": "image/jpeg",
"width": 245,
"height": 129,
"size": 4.12,
"path": null,
"url": "/uploads/thumbnail_aphex_11b34d4058.jpeg"
},
"large": {
"name": "large_aphex.jpeg",
"hash": "large_aphex_11b34d4058",
"ext": ".jpeg",
"mime": "image/jpeg",
"width": 1000,
"height": 525,
"size": 28.49,
"path": null,
"url": "/uploads/large_aphex_11b34d4058.jpeg"
},
"medium": {
"name": "medium_aphex.jpeg",
"hash": "medium_aphex_11b34d4058",
"ext": ".jpeg",
"mime": "image/jpeg",
"width": 750,
"height": 394,
"size": 18.95,
"path": null,
"url": "/uploads/medium_aphex_11b34d4058.jpeg"
},
"small": {
"name": "small_aphex.jpeg",
"hash": "small_aphex_11b34d4058",
"ext": ".jpeg",
"mime": "image/jpeg",
"width": 500,
"height": 263,
"size": 10.67,
"path": null,
"url": "/uploads/small_aphex_11b34d4058.jpeg"
}
},
"hash": "aphex_11b34d4058",
"ext": ".jpeg",
"mime": "image/jpeg",
"size": 37.07,
"url": "/uploads/aphex_11b34d4058.jpeg",
"previewUrl": null,
"provider": "local",
"provider_metadata": null,
"created_at": "2020-12-19T17:25:35.172Z",
"updated_at": "2020-12-19T17:25:35.183Z"
}
],
"categories": [
{
"id": 1,
"name": "Music",
"published_at": "2020-12-19T21:18:16.946Z",
"created_at": "2020-12-19T21:18:13.393Z",
"updated_at": "2020-12-19T21:18:16.961Z"
}
],
"artists": [
{
"id": 1,
"name": "Aphex Twin",
"bio": "Richard James is a pretty old guy by now but he was banging in the techno/ambient electronic scene in the late 80s and 90s. He's from Cornwall so must've been pretty bored on most days, which lead him to hack at computers and electronic sound generators. The rest is history.",
"published_at": "2020-12-19T21:42:33.225Z",
"created_at": "2020-12-19T21:42:03.445Z",
"updated_at": "2020-12-19T21:42:33.251Z",
"artist_image": []
}
]
}
Again -- all fields show if I console.log, but not image.url
Got it -- the image field is an array because I allowed multiple media on Strapi. Had to do event.image[0].url

Logstash nested array JSON parsing

I have a JSON log of my application which contains elements in a nested array form, here is the sample of it:-
{
"msgs": [{
"ts": "2017-09-04T07:07:45.6229372Z",
"tid": 25,
"eid": 1,
"lvl": "Information",
"cat": "Microsoft.AspNetCore.Hosting.Internal.WebHost",
"msg": {
"cnt": "Request starting HTTP/1.1 POST http://localhost:20001/Processor text/xml; charset=utf-8 685",
"Protocol": "HTTP/1.1",
"Method": "POST",
"ContentType": "text/xml; charset=utf-8",
"ContentLength": 685,
"Scheme": "http",
"Host": "localhost:20001",
"PathBase": "",
"Path": "/Processor",
"QueryString": ""
}
},
{
"ts": "2017-09-04T07:07:45.6229372Z",
"tid": 25,
"lvl": "Information",
"cat": "NCR.CP.Service.ServiceHostMiddleware",
"msg": {
"cnt": "REQ"
},
"data": {
"Headers": {
"Connection": "Keep-Alive",
"Content-Length": "685",
"Content-Type": "text/xml; charset=utf-8",
"Accept-Encoding": "gzip, deflate",
"Expect": "100-continue",
"Host": "localhost:20001",
"SOAPAction": "\"http://servereps.mtxeps.com/TransactionService/SendTransaction\""
}
}
},
{
"ts": "2017-09-04T07:07:45.6239372Z",
"tid": 25,
"lvl": "Information",
"cat": "NCR.CP.GatewayService.ProcessorTransactionService",
"msg": {
"cnt": "REQ"
},
"data": {
"Trace": "Aa10031<1C>Ab1<1C>Ac000101<1C>Ad20170616145857<1C>Ae10011<1C>AhVT00009<1C>ArY<1C>Be1812<1C>BfS<1C>BnDB<1C>Bo400296<1C>Bp4803<1C>BqDebit Card<1C>Br16<1C>Da300<1C>Dc0<1C>Dk840<1C>Ga01<1C>Gb1<1C>GfG<1C>GhB/GsF>O<1C>GkOE1<1C>Ia7325980B6B284759<1C>Ib8765432100324A00313<1C>Ic0043<1C>Ig3|1|MX2015-06<1C>IjgnkA7MdNlE2EB1c2B3jlz1G3Kf2U5S3x2H9W6ldIY7QpmlUzYcNHGg==|FFFF987654323D2007CD<1C>Nc5<1C>Oa18"
}
},
{
"ts": "2017-09-04T07:07:45.6249373Z",
"tid": 25,
"lvl": "Information",
"cat": "NCR.CP.GatewayService.TransactionProcessingEngine",
"msg": {
"cnt": "REQ"
},
"data": {
"request": {
"Version": "1.0",
"Server": {
"LogicalDatacenterId": 0,
"PhysicalDatacenterId": 0,
"UniqueId": "G00008D4F35EDADCD368",
"UniversalTimestamp": "2017-09-04T07:07:45.6249373Z"
},
"State": {
"Status": "InFlight"
},
"Tenant": {
"CompanyNumber": 10031,
"StoreNumber": 1,
"HostType": {
"Code": 7,
"Name": "ProdConcordHC"
},
"MerchantNumber": "",
"TerminalId": ""
},
"PointOfInteraction": {
"Client": {
"Type": "OpenEPS",
"CardType": "DB",
"CardName": "Debit Card",
"CommandSequence": "B/GsF>O"
},
"Lane": {
"Type": "Attended",
"Number": 1
},
"Terminal": {
"EMVCapabilities": "FullEMV",
"SerialNumber": "0043"
},
"PointOfSale": {
"ReferenceNumber": "VT00009",
"CashierNumber": "1"
},
"LocalTimestamp": "2017-06-16T14:58:57"
},
"Request": {
"MessageType": {
"Code": 0,
"Name": "Standard"
},
"TenderType": {
"Code": 1,
"Name": "Debit"
},
"TransactionType": {
"Code": 1,
"Name": "Purchase"
},
"EntryMode": "Swiped",
"AuditId": 10011,
"CardType": {
"TenderType": {
"Code": 0,
"Name": "Unknown"
},
"Code": 0,
"Name": "Unknown"
},
"AccountNumberFirstSix": "400296",
"AccountNumberLastFour": "4803",
"AccountNumberLength": 16,
"Card": {
"EncryptedTrack": {
"EncryptionType": "Hardware",
"EncryptionKeySerialNumber": "FFFF987654323D2007CD",
"EncryptedValue": "gnkA7MdNlE2EB1c2B3jlz1G3Kf2U5S3x2H9W6ldIY7QpmlUzYcNHGg=="
},
"EncryptedPIN": {
"EncryptionType": "PassThrough",
"EncryptionKeySerialNumber": "8765432100324A00313",
"EncryptedValue": "7325980B6B284759"
}
},
"Currency": {
"Number": 840
},
"Amount": 3.0,
"CashbackAmount": 0.0,
"AllowPartialAuthorization": true,
"Host": {
"HostType": {
"Code": 7,
"Name": "ProdConcordHC"
},
"Values": {
"HostProfileId": 1,
"CompanyNumber": 10031,
"StoreNumber": 1,
"StoreProfileId": 1,
"NumericStateCode": 0,
"AlphaStateCode": "NH",
"CheckAuthService": "3"
}
}
},
"Trace": {
"Path": [{
"Type": "OpenEPS",
"Value": "OE1"
},
{
"NodeId": 0,
"Type": "Gateway",
"Value": "GAT"
},
{
"NodeId": 0,
"ElapsedSeconds": 0.7458587,
"Type": "Tenant",
"Value": "TEN"
}]
}
},
"timeoutInMilliseconds": 45000
}
},
{
"ts": "2017-09-04T07:07:45.6259373Z",
"tid": 25,
"lvl": "Information",
"cat": "NCR.CP.SDK.TenantResolutionClient",
"msg": {
"cnt": "SEND"
},
"data": {
"RequestUri": "http://153.71.66.148:20002/TenantConfigurationService/v1/Resolution",
"Method": "POST",
"Headers": {
"Date": "Mon, 04 Sep 2017 07:07:45 GMT",
"User-Agent": "ConnectedPayments/1.0",
"x-ms-request-root-id": "6627de44-43a027c7567ddccd",
"x-ms-request-id": "|6627de44-43a027c7567ddccd.1.",
"Request-Id": "|6627de44-43a027c7567ddccd.1.",
"Correlation-Context": "UniqueId=G00008D4F35EDADCD368",
"Content-Type": "application/json; charset=utf-8",
"Content-Length": "181"
}
}
},
{
"ts": "2017-09-04T07:07:46.37098Z",
"tid": 25,
"lvl": "Information",
"cat": "NCR.CP.SDK.TenantResolutionClient",
"msg": {
"cnt": "RECV"
},
"data": {
"StatusCode": 200,
"ReasonPhrase": "OK",
"Headers": {
"Date": "Mon, 04 Sep 2017 07:07:46 GMT",
"Transfer-Encoding": "chunked",
"X-Unique-Id": "G00008D4F35EDADCD368",
"X-Node-Id": "0",
"Content-Type": "application/json; charset=utf-8"
}
}
},
{
"ts": "2017-09-04T07:07:46.37098Z",
"tid": 25,
"lvl": "Information",
"cat": "NCR.CP.GatewayService.TransactionProcessingEngine",
"msg": {
"cnt": "Resolution performed."
},
"data": {
"Response": {
"Content": {
"Company": {
"Number": 10031,
"Name": "Sprouts"
},
"TransactionProfile": {
"TransactionProfileId": 1,
"CompanyNumber": 10031,
"Number": 1000,
"Description": "Transaction Profile 1000"
},
"TransactionValidation": {
"TransactionValidationId": 1,
"TransactionProfileId": 1,
"MessageTypeCode": 0,
"TenderTypeCode": 1,
"TransactionTypeCode": 1,
"CardTypeCode": 0
},
"Store": {
"Number": 1,
"Name": "Store 1",
"QueueLaneNumber": 0
},
"StoreProfile": {
"StoreProfileId": 1,
"CompanyNumber": 10031,
"StoreNumber": 1,
"TransactionProfileId": 1,
"HostTypeCode": 7,
"MerchantNumber": "",
"TerminalId": ""
},
"HostProfile": {
"HostProfileId": 1,
"CompanyNumber": 10031,
"StoreNumber": 1,
"StoreProfileId": 1,
"NumericStateCode": 0,
"AlphaStateCode": "NH",
"CheckAuthService": "3"
}
},
"NodeId": 0,
"StatusCode": 200
},
"ElapsedSeconds": 0.7458587
}
},
{
"ts": "2017-09-04T07:07:46.37198Z",
"tid": 25,
"lvl": "Information",
"cat": "NCR.CP.SDK.TransactionAuthorizationClient",
"msg": {
"cnt": "SEND"
},
"data": {
"RequestUri": "http://ser22vvm211:8082/OrchestrationService/v1/Authorization",
"Method": "POST",
"Headers": {
"Date": "Mon, 04 Sep 2017 07:07:46 GMT",
"User-Agent": "ConnectedPayments/1.0",
"x-ms-request-root-id": "6627de44-43a027c7567ddccd",
"x-ms-request-id": "|6627de44-43a027c7567ddccd.2.",
"Request-Id": "|6627de44-43a027c7567ddccd.2.",
"Correlation-Context": "UniqueId=G00008D4F35EDADCD368",
"Content-Type": "application/json; charset=utf-8",
"Content-Length": "1821"
}
}
},
{
"ts": "2017-09-04T07:07:49.8941815Z",
"tid": 25,
"lvl": "Information",
"cat": "NCR.CP.SDK.TransactionAuthorizationClient",
"msg": {
"cnt": "RECV"
},
"data": {
"StatusCode": 200,
"ReasonPhrase": "OK",
"Headers": {
"Date": "Mon, 04 Sep 2017 07:07:49 GMT",
"Server": "Apache-Coyote/1.1",
"Content-Length": "1672",
"Content-Type": "application/json"
}
}
},
{
"ts": "2017-09-04T07:07:49.8951815Z",
"tid": 25,
"lvl": "Information",
"cat": "NCR.CP.GatewayService.TransactionProcessingEngine",
"msg": {
"cnt": "RSP"
},
"data": {
"ResponseTransaction": {
"Version": null,
"Server": {
"LogicalDatacenterId": 0,
"PhysicalDatacenterId": 0,
"TransactionId": 10909,
"UniqueId": "G00008D4F35EDADCD368",
"UniversalTimestamp": "2017-09-04T07:07:45.6249373Z"
},
"State": null,
"Tenant": {
"CompanyNumber": 10031,
"StoreNumber": 1,
"HostType": {
"Code": 7,
"Name": "ProdConcordHC"
},
"MerchantNumber": "",
"TerminalId": ""
},
"PointOfInteraction": {
"Client": {
"Type": "B/GsF>O",
"CardType": "DB",
"CardName": "Debit Card",
"CommandSequence": "B/GsF>O",
"Version": null
},
"Lane": {
"Type": "Attended",
"Number": 1
},
"Terminal": {
"EMVCapabilities": "Contact, ContactlessDisabled",
"Type": null,
"SerialNumber": null,
"EMVKernelVersion": null,
"EMVIdentifierCAPK": null,
"PINCapabilities": null
},
"PointOfSale": {
"CashierNumber": "1",
"ReferenceNumber": null
},
"LocalTimestamp": "2017-06-16T14:58:57",
"LocalTimeZoneOffset": null
},
"Request": {
"MessageType": null,
"EntryMode": null,
"CashbackAmount": 0.00,
"AllowPartialAuthorization": true,
"TenderType": null,
"TransactionType": null,
"ReversalType": null,
"ReferenceId": null,
"AuditId": null,
"AccountNumberFirstSix": null,
"AccountNumberLastFour": null,
"AccountNumberLength": null,
"CardType": null,
"PreviousTransaction": null,
"Card": null,
"Check": null,
"Identification": null,
"Currency": null,
"Amount": null,
"TipAmount": null,
"Host": null
},
"Response": {
"ErrorCode": 96,
"ErrorMessage": "E2G",
"IsApproved": false,
"ResponseCode": "96",
"HostResponseCode": "E2G",
"HostResponseMessage": "EDIT ER:OPT DATA",
"ApprovedAmount": 0.00,
"ApprovedCashbackAmount": 0.0,
"IsApprovedLocally": false,
"AuthorizationCode": null,
"ResponseMessage": null,
"BalanceAmount": null,
"Check": null,
"Currency": null,
"Card": null,
"Host": null
},
"Trace": {
"ElapsedSeconds": 4.2694351,
"Path": [{
"NodeId": 0,
"ElapsedSeconds": 4.2694351,
"Type": "Gateway",
"Value": "GAT"
}]
},
"Queue": null,
"SensitiveData": null,
"PreviousTransaction": null,
"Trace": null
}
}
},
{
"ts": "2017-09-04T07:07:49.8951815Z",
"tid": 25,
"lvl": "Information",
"cat": "NCR.CP.GatewayService.ProcessorTransactionService",
"msg": {
"cnt": "RSP"
},
"data": {
"Trace": "Aa10031<1C>Ab1<1C>Ac000101<1C>Ad20170616145857<1C>Ae10011<1C>Af96<1C>ArY<1C>BnDB<1C>BqDebit Card<1C>Db0<1C>Dc0<1C>Ga1<1C>Gb1<1C>GfG<1C>GhB/GsF>O<1C>GkGAT<1C>Jb96<1C>Ka7<1C>MbE2G<1C>Mg0<1C>Nc5<1C>Ya10909<1C>Yb0<1C>YcG00008D4F35EDADCD368"
}
},
{
"ts": "2017-09-04T07:07:49.8951815Z",
"tid": 25,
"lvl": "Information",
"cat": "NCR.CP.Service.ServiceHostMiddleware",
"msg": {
"cnt": "RSP"
},
"data": {
"Headers": {
"Date": "Mon, 04 Sep 2017 07:07:49 GMT",
"Transfer-Encoding": "chunked",
"Content-Type": "text/xml; charset=utf-8",
"X-Unique-Id": "G00008D4F35EDADCD368",
"X-Node-Id": "0"
}
}
},
{
"ts": "2017-09-04T07:07:49.8951815Z",
"tid": 25,
"eid": 2,
"lvl": "Information",
"cat": "Microsoft.AspNetCore.Hosting.Internal.WebHost",
"msg": {
"cnt": "Request finished in 4272.8738ms 200 text/xml; charset=utf-8",
"ElapsedMilliseconds": 4272.8738,
"StatusCode": 200,
"ContentType": "text/xml; charset=utf-8"
}
}],
"RequestId": "G00008D4F35EDADCD368",
"RequestPath": "/Processor",
"Action": "http://servereps.mtxeps.com/TransactionService/SendTransaction",
"Contract": "NCR.CP.GatewayService.IProcessorTransactionContract",
"OperationName": "SendTransaction",
"MethodName": "SendTransaction"
}
Here "msgs" element contains nested array object into it, so to create field of every elements inside the array object i had followed the mutate and split approach both:-
Mutate filter:-
mutate {
add_field => {
"ts" => "%{[doc][msgs][0][ts]}"
"tid1" => "%{[doc][msgs][0][tid]}"
"eid1" => "%{[doc][msgs][0][eid]}"
"lvl1" => "%{[doc][msgs][0][lvl]}"
"cat1" => "%{[doc][msgs][0][cat]}"
"msg1" => "%{[doc][msgs][0][msg]}"
"data" => "%{[doc][msgs][1][data]}"
"actual-message" =>"%{[doc][msgs][3][data][Trace]}"
"error" =>"%{[doc][msgs][5][ex][exs][0][ec]}"
"error-type" =>"%{[doc][msgs][5][ex][exs][0][typ]}"
}
}
This approach is static as my logs is occurring dynamically i.e position of error is not fixed as it may come in 6th array element or may be at 7th or 8th,
so i ignored this approach and followed the split filter approach:-
Split Filter in logstash config:-
input{
file{
path=>"C:\Logs\GatewayService\GatewayService-Processor.Transactions-20170830.slog"
}
}
split {
field=>"msgs"
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "g_index"
}
}
now it is showing error as:
[2017-09-19T17:40:07,557][WARN ][logstash.filters.split ] Only String and Array types are splittable. field:msg is of type = NilClass
so how should i able to retrieve every element in this JSON to be a field so as to visualize in kibana by applying metrics in dashboard.

How do I get the current MediaWiki version using the API?

Using the MediaWiki API how do I get the version number?
You need /w/api.php?action=query&format=json&prop=&meta=siteinfo. That will give you all you need (and a lot more). Here's what it returns from en.wikipedia.org:
{
"batchcomplete": "",
"query": {
"general": {
"mainpage": "Main Page",
"base": "https://en.wikipedia.org/wiki/Main_Page",
"sitename": "Wikipedia",
"logo": "//en.wikipedia.org/static/images/project-logos/enwiki.png",
"generator": "MediaWiki 1.30.0-wmf.2",
"phpversion": "5.6.99-hhvm",
"phpsapi": "srv",
"hhvmversion": "3.18.2",
"dbtype": "mysql",
"dbversion": "10.0.29-MariaDB",
"imagewhitelistenabled": "",
"langconversion": "",
"titleconversion": "",
"linkprefixcharset": "",
"linkprefix": "",
"linktrail": "/^([a-z]+)(.*)$/sD",
"legaltitlechars": " %!\"$&'()*,\\-.\\/0-9:;=?#A-Z\\\\^_`a-z~\\x80-\\xFF+",
"invalidusernamechars": "#:",
"fixarabicunicode": "",
"fixmalayalamunicode": "",
"git-hash": "b40805ff461884e48400adb3000fa06f9b6ff4c9",
"git-branch": "wmf/1.30.0-wmf.2",
"case": "first-letter",
"lang": "en",
"fallback": [],
"fallback8bitEncoding": "windows-1252",
"writeapi": "",
"maxarticlesize": 2097152,
"timezone": "UTC",
"timeoffset": 0,
"articlepath": "/wiki/$1",
"scriptpath": "/w",
"script": "/w/index.php",
"variantarticlepath": false,
"server": "//en.wikipedia.org",
"servername": "en.wikipedia.org",
"wikiid": "enwiki",
"time": "2017-06-05T23:28:54Z",
"misermode": "",
"uploadsenabled": "",
"maxuploadsize": 4294967296,
"minuploadchunksize": 1024,
"galleryoptions": {
"imagesPerRow": 0,
"imageWidth": 120,
"imageHeight": 120,
"captionLength": "",
"showBytes": "",
"mode": "traditional"
},
"thumblimits": [
120,
150,
180,
200,
220,
250,
300,
400
],
"imagelimits": [
{
"width": 320,
"height": 240
},
{
"width": 640,
"height": 480
},
{
"width": 800,
"height": 600
},
{
"width": 1024,
"height": 768
},
{
"width": 1280,
"height": 1024
}
],
"favicon": "//en.wikipedia.org/static/favicon/wikipedia.ico",
"centralidlookupprovider": "CentralAuth",
"allcentralidlookupproviders": [
"CentralAuth",
"local"
],
"interwikimagic": "",
"magiclinks": {
"ISBN": "",
"PMID": "",
"RFC": ""
},
"wmf-config": {
"wmfMasterDatacenter": "eqiad"
},
"pageviewservice-supported-metrics": {
"pageviews": {
"pageviews": ""
},
"siteviews": {
"pageviews": "",
"uniques": ""
},
"mostviewed": {
"pageviews": ""
}
}
}
}
}
I'm guessing you need the "generator" property there. If you like you can test it out in Wikipedia's API sandbox.