Related
For some reason vega is reading my data as 0 when the numbers range from 1-234.
I am attempting to show a visualisation of a chloropleth map of crypto-ownership by country.
The countries have been ranked 1-234 and that is meant to show on the tooltip however, this is being shown as 0 on the tooltip. How do I fix this.
Here is my code:
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"title":{
"text": "Crypto Ownership Worldwide",
"subtitle": "Source: FILL",
"anchor": "start"
},
"width":500,
"height":400,
"data": {
"url": "https://raw.githubusercontent.com/tomiwav/tomiwav.github.io/main/custom.geo%20(3).json",
"format":{"property": "features"}
},
"projection":{"type": "mercator"},
"transform": [
{
"lookup":"properties.name",
"from":{
"key": "Country",
"fields": ["Rank"],
"data":{
"url": "https://raw.githubusercontent.com/tomiwav/tomiwav.github.io/main/datarank.csv",
"format":{"type":"csv"}
}
}
}
],
"mark":{
"type": "geoshape",
"fill":"lightgray",
"stroke":"black",
"strokeWidth":0.5
},
"encoding": {
"color": {
"field": "Rank",
"type": "quantitative",
"scale": {
"domain":[234,1],
"scheme": "oranges"
}
},
"tooltip":[
{"field":"properties.name", "title":"Country"},
{"field":"Rank","type":"quantitative","title":"Number of Crypto Owners","format":".2f"}
]
},
"config": {"mark": {"invalid": null}
}
}
Your lookup was failing. You need a lower case "c" on country.
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"title": {
"text": "Crypto Ownership Worldwide",
"subtitle": "Source: FILL",
"anchor": "start"
},
"width": 500,
"height": 400,
"data": {
"url": "https://raw.githubusercontent.com/tomiwav/tomiwav.github.io/main/custom.geo%20(3).json",
"format": {"property": "features"}
},
"projection": {"type": "mercator"},
"transform": [
{
"lookup": "properties.name",
"from": {
"key": "country",
"fields": ["Rank"],
"data": {
"url": "https://raw.githubusercontent.com/tomiwav/tomiwav.github.io/main/datarank.csv",
"format": {"type": "csv"}
} }
}
],
"mark": {
"type": "geoshape",
"fill": "lightgray",
"stroke": "black",
"strokeWidth": 0.5
},
"encoding": {
"color": {
"field": "Rank",
"type": "quantitative",
"scale": {"domain": [234, 1], "scheme": "oranges"}
},
"tooltip": [
{"field": "properties.name", "title": "Country"},
{
"field": "Rank",
"type": "quantitative",
"title": "Number of Crypto Owners",
"format": ".2f"
}
]
},
"config": {"mark": {"invalid": null}}
}
Currently I'm developing an application which uses Prepr.io as API for fetching my own videos which are also stored in Prepr.io. When I'm fetching data with this link: https://cdn.prepr.io/publications?fields=items{file{cdn_files}} I get the following JSON as response:
Object {
"after": "YWZ0ZXJfMjU=",
"before": "YmVmb3JlXzA=",
"items": Array [
Object {
"changed_on": "2022-02-28T12:16:31+00:00",
"created_on": "2022-02-28T12:16:31+00:00",
"id": "905f950f-3e18-4b40-8c72-f8d3e509e546",
"items": Object {
"en-US": Object {
"beschikbaar_op_route": Object {
"items": Array [
Object {
"body": "Route Groningen stadspark",
"changed_on": null,
"created_on": "2022-02-28T12:13:10+00:00",
"id": "a3758c72-1074-4385-884e-34c4bd7d6e1d",
"label": "Tag",
"slug": "route-groningen-stadspark",
},
Object {
"body": "Route Leeuwarden Kalverdijkje",
"changed_on": null,
"created_on": "2022-02-28T12:13:28+00:00",
"id": "cc3cbe4b-536a-40e7-b69b-8bdddc24d445",
"label": "Tag",
"slug": "route-leeuwarden-kalverdijkje",
},
],
"label": "Tag",
},
"file": Object {
"items": Array [
Object {
"author": null,
"body": null,
"cdn_files": Object {
"items": Array [
Object {
"bucket": null,
"cdn": "BunnyCdn",
"changed_on": null,
"created_on": "2021-05-11T13:02:22+00:00",
"extension": null,
"file": "c7f6339d-e686-41a1-82ef-e3fbb9ebb425.mp4",
"id": "51fbad9a-70a9-4f6e-abfb-59b7a3ab2857",
"label": "CdnFile",
"presets": Array [],
"profile": null,
"url": "https://5ge7hcv8ge1k.b-cdn.net/c7f6339d-e686-41a1-82ef-e3fbb9ebb425.mp4",
},
],
"total": 1,
},
"changed_on": "2022-01-06T15:03:34+00:00",
"created_on": "2021-05-11T13:02:07+00:00",
"duration": 32640,
"ended_on": null,
"extension": "mp4",
"height": 720,
"id": "c7f6339d-e686-41a1-82ef-e3fbb9ebb425",
"label": "Video",
"mime_type": "video/mp4",
"name": "Stang in de nek video",
"original_name": "Stang in de nek",
"reference_id": null,
"replaceable": true,
"started_on": null,
"status": null,
"width": 1280,
},
],
"label": "Asset",
},
"image": Object {
"items": Array [
Object {
"author": null,
"body": null,
"changed_on": "2021-03-16T08:41:28+00:00",
"created_on": "2021-03-16T08:41:28+00:00",
"extension": "jpg",
"height": 1280,
"id": "9cade08f-5d16-41d1-8007-d18a08f0cddd",
"label": "Photo",
"mime_type": "image/jpeg",
"name": "b053b802-abf8-47b4-888a-9304712c0a41",
"original_name": "b053b802-abf8-47b4-888a-9304712c0a41",
"reference_id": null,
"replaceable": true,
"status": null,
"width": 1920,
},
],
"label": "Asset",
},
"kenmerken": Object {
"items": Array [
Object {
"body": "Rollator",
"changed_on": null,
"created_on": "2022-01-06T14:48:37+00:00",
"id": "0af8af83-d353-4d05-aff2-b86be1bf12b8",
"label": "Tag",
"slug": "rollator",
},
],
"label": "Tag",
},
"niveau": Object {
"items": Array [
Object {
"body": "Level 1",
"changed_on": null,
"created_on": "2021-05-06T10:12:28+00:00",
"id": "5d7cb8be-7bb2-4b96-9910-744303470e81",
"label": "Tag",
"slug": "level-1",
},
Object {
"body": "Level 2",
"changed_on": null,
"created_on": "2021-05-06T10:12:30+00:00",
"id": "eb867180-2343-4d44-a7a1-9cfecb127a69",
"label": "Tag",
"slug": "level-2",
},
],
"label": "Tag",
},
"title": Object {
"body": "bla",
"changed_on": null,
"created_on": "2022-02-28T12:16:31+00:00",
"format": null,
"id": "655331e9-5dcd-4fe9-8eeb-fed17d0a9155",
"label": "Text",
},
},
},
"label": "Publication",
"publish_on": Object {
"en-US": "2022-02-28T12:16:00+00:00",
},
"read_time": Object {
"en-US": 1,
},
},
Object {
"changed_on": "2022-01-06T15:01:57+00:00",
"created_on": "2022-01-06T15:01:57+00:00",
"id": "20a86707-6144-461f-9b2a-7ab27b834b79",
"items": Object {
"en-US": Object {
"active": Object {
"changed_on": null,
"created_on": "2022-01-06T15:01:57+00:00",
"id": "d18f7a7e-785c-4a0f-b7ed-e60dc3a87f58",
"label": "Boolean",
"value": "1",
},
"audience": Object {
"items": Array [
Object {
"body": "Bewoner",
"changed_on": null,
"created_on": "2022-01-06T14:42:56+00:00",
"id": "d714c04b-5e6e-45ec-b082-dfa791b44fde",
"label": "Tag",
"slug": "bewoner",
},
],
"label": "Tag",
},
"auto_increase": Object {
"changed_on": null,
"created_on": "2022-01-06T15:01:57+00:00",
"id": "c6c08428-91f0-463c-b63b-ad636104d58a",
"label": "Boolean",
"value": "1",
},
"auto_increase_level": Object {
"changed_on": null,
"created_on": "2022-01-06T15:01:57+00:00",
"id": "649fb6e6-ba05-47b5-a2d3-1224dce58c21",
"label": "Integer",
"value": 3,
},
"characteristics": Object {
"items": Array [
Object {
"body": "Man",
"changed_on": null,
"created_on": "2022-01-06T14:48:37+00:00",
"id": "5d6333be-2cee-49ce-a945-e292a4d88d1c",
"label": "Tag",
"slug": "man",
},
Object {
"body": "Vrouw",
"changed_on": null,
"created_on": "2022-01-06T14:48:37+00:00",
"id": "4ecbc422-dd5f-48d6-aa09-2180627b6f0c",
"label": "Tag",
"slug": "vrouw",
},
],
"label": "Tag",
},
"program_comment": Object {
"body": "probeersel",
"changed_on": null,
"created_on": "2022-01-06T15:01:57+00:00",
"format": null,
"id": "9d5860cd-94f6-4b99-ad82-eeddec5792f4",
"label": "Text",
},
"program_title": Object {
"body": "Test programma 1",
"changed_on": null,
"created_on": "2022-01-06T15:01:57+00:00",
"format": null,
"id": "0f82e55c-609a-4e19-b68d-42d249d950bc",
"label": "Text",
},
"routine": Object {
"items": Array [
Object {
"changed_on": "2022-01-06T15:01:02+00:00",
"created_on": "2022-01-06T15:00:46+00:00",
"id": "56e685fc-00c7-438b-93b7-ca1557dff671",
"label": "Publication",
"publish_on": Object {
"en-US": "2022-01-06T15:00:00+00:00",
},
"read_time": Object {
"en-US": 1,
},
},
Object {
"changed_on": "2022-01-06T15:00:33+00:00",
"created_on": "2022-01-06T15:00:33+00:00",
"id": "f54a9dc3-1133-4023-8c6e-634a321d22b6",
"label": "Publication",
"publish_on": Object {
"en-US": "2022-01-06T15:00:00+00:00",
},
"read_time": Object {
"en-US": 1,
},
},
],
"label": "Publication",
},
"video": Object {
"items": Array [
Object {
"changed_on": "2022-02-28T12:15:42+00:00",
"created_on": "2022-01-06T14:59:30+00:00",
"id": "a758aa90-3dc4-4382-ae59-fa43ca90eac3",
"label": "Publication",
"publish_on": Object {
"en-US": "2022-01-06T14:58:00+00:00",
},
"read_time": Object {
"en-US": 1,
},
},
],
"label": "Publication",
},
},
},
"label": "Publication",
"publish_on": Object {
"en-US": "2022-01-06T15:01:00+00:00",
},
"read_time": Object {
"en-US": 1,
},
},
Object {
"changed_on": "2022-01-06T15:01:02+00:00",
"created_on": "2022-01-06T15:00:46+00:00",
"id": "56e685fc-00c7-438b-93b7-ca1557dff671",
"items": Object {
"en-US": Object {
"title": Object {
"body": "Test routine 2",
"changed_on": null,
I really want to filter the data so I can get for example only the videos with 'niveau' > 'level 1' But i don't know how i can get the data. In the response i get 'Object' but what does 'Object' means? Currently i'm developing the application in React Native Expo and the code which i use is:
const loadVideo = async() => {
fetch('https://cdn.prepr.io/publications?fields=items{file{cdn_files}}', {
method: 'get',
headers: {
Authorization: 'Bearer {Token}'}
})
.then((r) => r.json())
.then((r) => {
console.log(r)
})
.catch((err) => {
console.log(err)
})
}
The following is my json response from one of my APIs. I am trying to print image URL on console. You will see response is list of requests with each request having an array of images (json objects)
[
{
"image": [
{
"_id": "5fbfdc75aea26e00484a787a",
"name": "WhatsApp Image 2020-10-23 at 11.55.25 AM.jpeg",
"alternativeText": "",
"caption": "",
"hash": "Whats_App_Image_2020_10_23_at_11_55_25_AM_773f08e059",
"ext": ".jpeg",
"mime": "image/jpeg",
"size": 50.67,
"width": 590,
"height": 576,
"url": "/uploads/Whats_App_Image_2020_10_23_at_11_55_25_AM_773f08e059.jpeg",
"formats": {
"thumbnail": {
"name": "thumbnail_WhatsApp Image 2020-10-23 at 11.55.25 AM.jpeg",
"hash": "thumbnail_Whats_App_Image_2020_10_23_at_11_55_25_AM_773f08e059",
"ext": ".jpeg",
"mime": "image/jpeg",
"width": 160,
"height": 156,
"size": 5.97,
"path": null,
"url": "/uploads/thumbnail_Whats_App_Image_2020_10_23_at_11_55_25_AM_773f08e059.jpeg"
},
"small": {
"name": "small_WhatsApp Image 2020-10-23 at 11.55.25 AM.jpeg",
"hash": "small_Whats_App_Image_2020_10_23_at_11_55_25_AM_773f08e059",
"ext": ".jpeg",
"mime": "image/jpeg",
"width": 500,
"height": 488,
"size": 41.95,
"path": null,
"url": "/uploads/small_Whats_App_Image_2020_10_23_at_11_55_25_AM_773f08e059.jpeg"
}
},
"provider": "local",
"related": [
"5fbfdc7eaea26e00484a787b"
],
"createdAt": "2020-11-26T16:48:53.715Z",
"updatedAt": "2020-11-26T16:49:02.626Z",
"__v": 0,
"id": "5fbfdc75aea26e00484a787a"
}
],
"_id": "5fbfdc7eaea26e00484a787b",
"title": "I want an center table",
"description": "I want a 3x3 center table with Indian marble top",
"createdAt": "2020-11-26T16:49:02.619Z",
"updatedAt": "2020-11-26T17:23:40.655Z",
"__v": 0,
"category": {
"_id": "5fbfe21d0bbf020065dd0b1e",
"category_name": "Furniture",
"createdAt": "2020-11-26T17:13:01.743Z",
"updatedAt": "2020-11-26T17:13:01.754Z",
"__v": 0,
"id": "5fbfe21d0bbf020065dd0b1e"
},
"id": "5fbfdc7eaea26e00484a787b"
},
{
"image": [
{
"_id": "5fc073aaf41381008738f53a",
"name": "1RK-Apartment-for-Sale-in-Nalasopara-East-Mumbai-at-Sai-Krupa-Chawl-Listing-Photo_Kitchen.jpeg",
"alternativeText": "",
"caption": "",
"hash": "1_RK_Apartment_for_Sale_in_Nalasopara_East_Mumbai_at_Sai_Krupa_Chawl_Listing_Photo_Kitchen_90475427e3",
"ext": ".jpeg",
"mime": "image/jpeg",
"size": 12.22,
"width": 300,
"height": 300,
"url": "/uploads/1_RK_Apartment_for_Sale_in_Nalasopara_East_Mumbai_at_Sai_Krupa_Chawl_Listing_Photo_Kitchen_90475427e3.jpeg",
"formats": {
"thumbnail": {
"name": "thumbnail_1RK-Apartment-for-Sale-in-Nalasopara-East-Mumbai-at-Sai-Krupa-Chawl-Listing-Photo_Kitchen.jpeg",
"hash": "thumbnail_1_RK_Apartment_for_Sale_in_Nalasopara_East_Mumbai_at_Sai_Krupa_Chawl_Listing_Photo_Kitchen_90475427e3",
"ext": ".jpeg",
"mime": "image/jpeg",
"width": 156,
"height": 156,
"size": 6.45,
"path": null,
"url": "/uploads/thumbnail_1_RK_Apartment_for_Sale_in_Nalasopara_East_Mumbai_at_Sai_Krupa_Chawl_Listing_Photo_Kitchen_90475427e3.jpeg"
}
},
"provider": "local",
"related": [
"5fc07407f41381008738f53c"
],
"createdAt": "2020-11-27T03:34:02.177Z",
"updatedAt": "2020-11-27T03:35:35.325Z",
"__v": 0,
"id": "5fc073aaf41381008738f53a"
},
{
"_id": "5fc073fdf41381008738f53b",
"name": "images.jpeg",
"alternativeText": "",
"caption": "",
"hash": "images_4ba1796688",
"ext": ".jpeg",
"mime": "image/jpeg",
"size": 9.55,
"width": 351,
"height": 144,
"url": "/uploads/images_4ba1796688.jpeg",
"formats": {
"thumbnail": {
"name": "thumbnail_images.jpeg",
"hash": "thumbnail_images_4ba1796688",
"ext": ".jpeg",
"mime": "image/jpeg",
"width": 245,
"height": 101,
"size": 6.44,
"path": null,
"url": "/uploads/thumbnail_images_4ba1796688.jpeg"
}
},
"provider": "local",
"related": [
"5fc07407f41381008738f53c"
],
"createdAt": "2020-11-27T03:35:25.211Z",
"updatedAt": "2020-11-27T03:35:35.325Z",
"__v": 0,
"id": "5fc073fdf41381008738f53b"
}
],
"_id": "5fc07407f41381008738f53c",
"title": "pest control के लिए",
"description": "हमारा घर 700 वर्गफुट का है",
"createdAt": "2020-11-27T03:35:35.313Z",
"updatedAt": "2020-11-27T03:36:20.592Z",
"__v": 0,
"category": {
"_id": "5fc07424f41381008738f53f",
"category_name": "Pest Control",
"createdAt": "2020-11-27T03:36:04.739Z",
"updatedAt": "2020-11-27T03:36:04.748Z",
"__v": 0,
"id": "5fc07424f41381008738f53f"
},
"id": "5fc07407f41381008738f53c"
}
]
I now want to show Image URL and referring it in following manner in React Native.
Following is React Native code for view
<View>
{isLoading ? <ActivityIndicator/> : (
<FlatList
data={data}
keyExtractor={({ id }, index) => id}
renderItem={ renderItem }
/>
)}
</View>
and renderItem is defined as following
function renderItem({ item }) {
console.log(item.image[0].name);
}
and I get following error
undefined is not an object (evaluating 'item.image[0]')
Can you point where am I going wrong?
You're not reading data properly. As you're using nested JSON object so you can access data using the following approaches:
For Single Image:
item[0].image[0].url
For all the Images:
item.forEach(function(value, key) {
value.image.map(image => console.log(image.url));
});
I have tried your code in react native expo snack it's working fine Expo Snack Link
I am new to getting JSON into SQL Server 2016, I thought I had it down, but I notice that I am missing some details from the array, looking at the image, there are four address', but I saw there are some more address' missing for example Burrows Rd, and Urana RD. How can I make sure that all the address' captured?
https://i.stack.imgur.com/erzBV.jpg
#json nvarchar(max)
#json = N'{
"response": [
{
"application": {
"info": {
"dat_id": "010.2018.00036494.001",
"development_type": "Residential - Single new dwelling",
"application_type": "DA",
"last_modified_date": "2018-12-03T11:35:24+11:00",
"description": "Residence, Garage & Colorbond Shed, Demolition of Existing Residence & Tree Removal",
"authority": {
"ref": "http://gemini:82/ApplicationTracker/atdis/1.0",
"name": "AlburyCity"
},
"lodgement_date": "2018-10-26T00:00:00+11:00",
"determination_date": null,
"determination_type": "Pending",
"status": "In Progress",
"notification_start_date": null,
"notification_end_date": null,
"officer": "David Flood",
"estimated_cost": "Not applicable.",
"related_apps": [ ]
},
"reference": {
"more_info_url": "http://gemini:82/ApplicationTracker/Application/ApplicationDetails/010.2018.00036494.001/",
"comments_url": null
},
"locations": [
{
"land_title_ref": {
"torrens": {
"lot": "11",
"section": null,
"dpsp_id": "DP 1031272"
}
},
"address": {
"street": "680 Centaur RD",
"suburb": "HAMILTON VALLEY",
"state": "NSW",
"postcode": "2641"
},
"geometry": null
},
{
"land_title_ref": {
"torrens": {
"lot": "11",
"section": null,
"dpsp_id": "DP 1031272"
}
},
"address": {
"street": "Urana RD",
"suburb": "HAMILTON VALLEY",
"state": "NSW",
"postcode": "2641"
},
"geometry": null
},
{
"land_title_ref": {
"torrens": {
"lot": "11",
"section": null,
"dpsp_id": "DP 1031272"
}
},
"address": {
"street": "Burrows RD",
"suburb": "HAMILTON VALLEY",
"state": "NSW",
"postcode": "2641"
},
"geometry": null
}
],
"events": [
{
"id": "3680347",
"timestamp": "2018-11-01T15:58:00+11:00",
"description": "Public Notification",
"event_type": "PNOT",
"status": "COMP"
},
{
"id": "3680348",
"timestamp": "2018-11-01T15:58:00+11:00",
"description": "Referral Engineering",
"event_type": "ENG",
"status": "COMP"
},
{
"id": "3680349",
"timestamp": "2018-11-01T15:59:00+11:00",
"description": "Referal Parks & Recreation",
"event_type": "TREE",
"status": "COMP"
},
{
"id": "3680350",
"timestamp": "2018-11-01T16:00:00+11:00",
"description": "Acknowledgement to Applicant",
"event_type": "ACKN",
"status": "COMP"
},
{
"id": "3683617",
"timestamp": "2018-11-21T14:59:00+11:00",
"description": "Site Assessment Inspection",
"event_type": "SITE",
"status": "PASS"
},
{
"id": "3685155",
"timestamp": "2018-12-03T11:37:00+11:00",
"description": "Assessment Report",
"event_type": "ASS3",
"status": "COMP"
}
],
"documents": [
{
"ref": "DOC18/163129",
"title": "Statement of Environmental Effects - SEE",
"document_url": "http://gemini:82/ApplicationTracker/atdis/1.0/Document/Download?key=6hF7YEiv0qE=&fileName=Statement+of+Environmental+Effects+-+SEE.PDF"
},
{
"ref": "DOC18/163139",
"title": "Site Plan and Elevations",
"document_url": "http://gemini:82/ApplicationTracker/atdis/1.0/Document/Download?key=1Gv3GVOIHCM=&fileName=Site+Plan+and+Elevations.PDF"
}
],
"people": [
{
"name": "Karyn Ford",
"role": "Applicant",
"contact": "6023 8287"
}
],
"extended": {
"software_vendor": "Civica",
"software_vendor_url": "http://www.civica.com.au"
}
}
},
{
"application": {
"info": {
"dat_id": "017.2018.00036017.001",
"development_type": "Subdivision Only",
"application_type": "SCC",
"last_modified_date": "2018-12-03T10:19:25+11:00",
"description": "Roads, Sewer, Water & Drainage for Two (2) Lot Torrens Title Subdivisi on",
"authority": {
"ref": "http://gemini:82/ApplicationTracker/atdis/1.0",
"name": "AlburyCity"
},
"lodgement_date": "2018-11-14T00:00:00+11:00",
"determination_date": "2018-11-29T00:00:00+11:00",
"determination_type": "Approved under delegation",
"status": "Determined",
"notification_start_date": null,
"notification_end_date": null,
"officer": "Sharna Holland",
"estimated_cost": "Not applicable.",
"related_apps": [ "http://gemini:82/ApplicationTracker/atdis/1.0/010.2018.00036017.001.json" ]
},
"reference": {
"more_info_url": "http://gemini:82/ApplicationTracker/Application/ApplicationDetails/017.2018.00036017.001/",
"comments_url": null
},
"locations": [
{
"land_title_ref": {
"torrens": {
"lot": "A",
"section": null,
"dpsp_id": "DP 161410"
}
},
"address": {
"street": "419 Hovell ST",
"suburb": "SOUTH ALBURY",
"state": "NSW",
"postcode": "2640"
},
"geometry": null
},
{
"land_title_ref": {
"torrens": {
"lot": "A",
"section": null,
"dpsp_id": "DP 161410"
}
},
"address": {
"street": "Charles ST",
"suburb": "SOUTH ALBURY",
"state": "NSW",
"postcode": "2640"
},
"geometry": null
}
],
"events": [
{
"id": "3683888",
"timestamp": "2018-11-23T14:03:00+11:00",
"description": "Acknowledgement to Applicant",
"event_type": "ACKN",
"status": "COMP"
},
{
"id": "3683902",
"timestamp": "2018-11-23T15:21:00+11:00",
"description": "Referral Engineering",
"event_type": "ENG",
"status": "COMP"
},
{
"id": "3683903",
"timestamp": "2018-11-23T15:21:00+11:00",
"description": "Referral Building Surveyor 3",
"event_type": "BS3",
"status": "COMP"
},
{
"id": "3683904",
"timestamp": "2018-11-23T15:21:00+11:00",
"description": "Referral Trainee Town Planner",
"event_type": "TTP1",
"status": "COMP"
},
{
"id": "3684791",
"timestamp": "2018-11-29T14:36:00+11:00",
"description": "Collected Determination",
"event_type": "COLL",
"status": "COMP"
}
],
"documents": [
{
"ref": "DOC18/177392",
"title": "Subdivision Works Certificate",
"document_url": "http://gemini:82/ApplicationTracker/atdis/1.0/Document/Download?key=8qU1Pkawfvg=&fileName=Subdivision+Works+Certificate.PDF"
}
],
"people": [
{
"name": "Eslers Land Consulting",
"role": "Applicant",
"contact": "6021 1322"
}
],
"extended": {
"software_vendor": "Civica",
"software_vendor_url": "http://www.civica.com.au"
}
}
},
{
"application": {
"info": {
"dat_id": "010.2016.00034838.001",
"development_type": "Residential - New multi unit",
"application_type": "DA",
"last_modified_date": "2018-12-03T09:36:09+11:00",
"description": "Twenty (20) Detached Self Contained Residences - Kensington Gardens Retirement Village",
"authority": {
"ref": "http://gemini:82/ApplicationTracker/atdis/1.0",
"name": "AlburyCity"
},
"lodgement_date": "2016-08-17T00:00:00+10:00",
"determination_date": "2016-10-24T00:00:00+11:00",
"determination_type": "Approved under delegation",
"status": "Determined",
"notification_start_date": null,
"notification_end_date": null,
"officer": "Christopher Eldred",
"estimated_cost": "Not applicable.",
"related_apps": [ "http://gemini:82/ApplicationTracker/atdis/1.0/011.2016.00034838.001.json", "http://gemini:82/ApplicationTracker/atdis/1.0/011.2016.00034838.002.json", "http://gemini:82/ApplicationTracker/atdis/1.0/011.2016.00034838.003.json", "http://gemini:82/ApplicationTracker/atdis/1.0/011.2016.00034838.004.json", "http://gemini:82/ApplicationTracker/atdis/1.0/011.2016.00034838.005.json", "http://gemini:82/ApplicationTracker/atdis/1.0/011.2016.00034838.006.json", "http://gemini:82/ApplicationTracker/atdis/1.0/011.2016.00034838.007.json", "http://gemini:82/ApplicationTracker/atdis/1.0/011.2016.00034838.008.json", "http://gemini:82/ApplicationTracker/atdis/1.0/011.2016.00034838.009.json", "http://gemini:82/ApplicationTracker/atdis/1.0/011.2016.00034838.010.json", "http://gemini:82/ApplicationTracker/atdis/1.0/011.2016.00034838.011.json", "http://gemini:82/ApplicationTracker/atdis/1.0/011.2016.00034838.012.json" ]
},
"reference": {
"more_info_url": "http://gemini:82/ApplicationTracker/Application/ApplicationDetails/010.2016.00034838.001/",
"comments_url": null
},
"locations": [
{
"land_title_ref": {
"torrens": {
"lot": "2",
"section": null,
"dpsp_id": "DP 874732"
}
},
"address": {
"street": "100 Table Top RD",
"suburb": "THURGOONA",
"state": "NSW",
"postcode": "2640"
},
"geometry": null
}
],
"events": [
{
"id": "3583145",
"timestamp": "2016-08-17T14:13:00+10:00",
"description": "Further Information Requested",
"event_type": "INFO",
"status": "COMP"
},
{
"id": "3573096",
"timestamp": "2016-08-18T15:34:00+10:00",
"description": "Public Notification",
"event_type": "PNOT",
"status": "COMP"
},
{
"id": "3573097",
"timestamp": "2016-08-18T15:37:00+10:00",
"description": "Referral Building Surveyor 2",
"event_type": "BS2",
"status": "COMP"
},
{
"id": "3573098",
"timestamp": "2016-08-18T15:37:00+10:00",
"description": "Referral Plumbing Inspector",
"event_type": "PI",
"status": "COMP"
},
{
"id": "3573099",
"timestamp": "2016-08-18T15:37:00+10:00",
"description": "Referral Engineering",
"event_type": "ENG",
"status": "COMP"
},
{
"id": "3573100",
"timestamp": "2016-08-18T15:38:00+10:00",
"description": "Referral Environmental Planner",
"event_type": "ENV",
"status": "COMP"
},
{
"id": "3573103",
"timestamp": "2016-08-18T15:43:43+10:00",
"description": "Acknowledgement to Applicant",
"event_type": "ACKN",
"status": "COMP"
},
{
"id": "3575194",
"timestamp": "2016-09-06T00:00:00+10:00",
"description": "Assessment Report",
"event_type": "ASS3",
"status": "COMP"
}
],
"documents": [
{
"ref": "DOC16/209893",
"title": "Statement of Environmental Effects - SEE",
"document_url": "http://gemini:82/ApplicationTracker/atdis/1.0/Document/Download?key=sQkVV9rEsTU=&fileName=Statement+of+Environmental+Effects+-+SEE.PDF"
},
{
"ref": "DOC16/209896",
"title": "Site Plan & Elevations",
"document_url": "http://gemini:82/ApplicationTracker/atdis/1.0/Document/Download?key=3dRqEZHzGeo=&fileName=Site+Plan+%26+Elevations.PDF"
},
{
"ref": "DOC16/211819",
"title": "Assessment Report",
"document_url": "http://gemini:82/ApplicationTracker/atdis/1.0/Document/Download?key=DVTQkQQqbns=&fileName=Assessment+Report.PDF"
},
{
"ref": "DOC16/240764",
"title": "Development Consent",
"document_url": "http://gemini:82/ApplicationTracker/atdis/1.0/Document/Download?key=TY+Y3zjyDKw=&fileName=Development+Consent.PDF"
}
],
"people": [
{
"name": "Kensington Gardens Lifestyle Estates",
"role": "Applicant",
"contact": "6049 3100"
}
],
"extended": {
"software_vendor": "Civica",
"software_vendor_url": "http://www.civica.com.au"
}
}
},
{
"application": {
"info": {
"dat_id": "010.2018.00036468.001",
"development_type": "Residential - Single new dwelling",
"application_type": "DA",
"last_modified_date": "2018-11-30T17:17:25+11:00",
"description": "Residence, Garage and Retaining Walls",
"authority": {
"ref": "http://gemini:82/ApplicationTracker/atdis/1.0",
"name": "AlburyCity"
},
"lodgement_date": "2018-10-19T00:00:00+11:00",
"determination_date": "2018-11-26T00:00:00+11:00",
"determination_type": "Approved under delegation",
"status": "Determined",
"notification_start_date": null,
"notification_end_date": null,
"officer": "David Flood",
"estimated_cost": "Not applicable.",
"related_apps": [ "http://gemini:82/ApplicationTracker/atdis/1.0/011.2018.00036468.001.json" ]
},
"reference": {
"more_info_url": "http://gemini:82/ApplicationTracker/Application/ApplicationDetails/010.2018.00036468.001/",
"comments_url": null
},
"locations": [
{
"land_title_ref": {
"torrens": {
"lot": "218",
"section": null,
"dpsp_id": "DP 1228226"
}
},
"address": {
"street": "20 Stockman CRCT",
"suburb": "THURGOONA",
"state": "NSW",
"postcode": "2640"
},
"geometry": null
}
],
"events": [
{
"id": "3678966",
"timestamp": "2018-10-25T10:47:00+11:00",
"description": "Public Notification",
"event_type": "PNOT",
"status": "COMP"
},
{
"id": "3678967",
"timestamp": "2018-10-25T10:48:00+11:00",
"description": "Referral Engineering",
"event_type": "ENG",
"status": "COMP"
},
{
"id": "3678974",
"timestamp": "2018-10-25T10:51:00+11:00",
"description": "Acknowledgement to Applicant",
"event_type": "ACKN",
"status": "COMP"
},
{
"id": "3681955",
"timestamp": "2018-11-01T15:49:00+11:00",
"description": "Site Assessment Inspection",
"event_type": "SITE",
"status": "COMP"
},
{
"id": "3684251",
"timestamp": "2018-11-27T10:24:00+11:00",
"description": "Collected Determination",
"event_type": "COLL",
"status": "COMP"
}
],
"documents": [
{
"ref": "DOC18/159026",
"title": "Statement of Environmental Effects - SEE",
"document_url": "http://gemini:82/ApplicationTracker/atdis/1.0/Document/Download?key=MaiWkTs8V+g=&fileName=Statement+of+Environmental+Effects+-+SEE.PDF"
},
{
"ref": "DOC18/159033",
"title": "Site Plan and Elevations and Superseded Plan",
"document_url": "http://gemini:82/ApplicationTracker/atdis/1.0/Document/Download?key=2xpqra8gNb0=&fileName=Site+Plan+and+Elevations+and+Superseded+Plan.PDF"
},
{
"ref": "DOC18/162569",
"title": "Assessment Report - Bldg Residential",
"document_url": "http://gemini:82/ApplicationTracker/atdis/1.0/Document/Download?key=bKYCMP01aJE=&fileName=Assessment+Report+-+Bldg+Residential.PDF"
},
{
"ref": "DOC18/168584",
"title": "Development Consent",
"document_url": "http://gemini:82/ApplicationTracker/atdis/1.0/Document/Download?key=SxGG/yKi68s=&fileName=Development+Consent.PDF"
}
],
"people": [
{
"name": "Alatalo Bros",
"role": "Applicant",
"contact": "02 6055 0180"
}
],
"extended": {
"software_vendor": "Civica",
"software_vendor_url": "http://www.civica.com.au"
}
}
}
],
"count": 4,
"pagination": {
"previous": null,
"next": 2,
"current": 1,
"per_page": 4,
"count": 24091,
"pages": 6023
}
}'
select *
from OPENJSON(#json, '$.response')
with
([lot] varchar(200) '$.application.locations[0].land_title_ref.torrens.lot',
[section] varchar(200) '$.application.locations[0].land_title_ref.torrens.section',
[dpsp_id] varchar(200) '$.application.locations[0].land_title_ref.torrens.dpsp_id',
[Street] varchar(200) '$.application.locations[0].address.street',
[suburb] varchar(200) '$.application.locations[0].address.suburb',
[state] varchar(200) '$.application.locations[0].address.state',
[postcode] varchar(200) '$.application.locations[0].address.postcode',
[geometry] varchar(200) '$.application.locations[0].geometry'
)
Try this:
select L.*
from OPENJSON(#json,'$.response') R
CROSS APPLY OPENJSON(R.[value], '$.application.locations')
with
(
[lot] varchar(200) '$.land_title_ref.torrens.lot',
[section] varchar(200) '$.land_title_ref.torrens.section',
[dpsp_id] varchar(200) '$.land_title_ref.torrens.dpsp_id',
[Street] varchar(200) '$.address.street',
[suburb] varchar(200) '$.address.suburb',
[state] varchar(200) '$.address.state',
[postcode] varchar(200) '$.address.postcode',
[geometry] varchar(200) '$.geometry'
) L
The locations is an array, so we need to use cross apply and OPENSJON to get all elements.
I have to index a json to Elastic which look like the below format. My problem is that the key "variable" is array that contains json objects (I thought about "nested" datatype of Elastic) but some of those objects it's possible to contain nested json arrays inside them. (see variable CUSTOMERS).
POST /example_data/data {
"process_name": "TEST_PROCESS",
"process_version ": 0,
"process_id": "1111",
"activity_id": "111",
"name": "update_data",
"username": "testUser",
"datetime": "2018-01-01 10:00:00",
"variables": [{
"name": "ΒΑΝΚ",
"data_type": "STRING",
"value": "EUROBANK"
},{
"name": "CITY",
"data_type": "STRING",
"value": "LONDON"
}, {
"name": "CUSTOMERS",
"data_type": "ENTITY",
"value": [{
"variables": [{
"name": "CUSTOMER_NAME",
"data_type": "STRING",
"value": "JOHN"
}, {
"name": " CUSTOMER_CITY",
"data_type": "STRING",
"value": "LONDON"
}
]
}
]
}, {
"name": "CUSTOMERS",
"data_type": "ENTITY",
"value": [{
"variables": [{
"name": "CUSTOMER_NAME",
"data_type": "STRING",
"value": "ΑΘΗΝΑ"
}, {
"name": " CUSTOMER_CITY ",
"data_type": "STRING",
"value": "LIVERPOOL"
}, {
"name": " CUSTOMER_NUMBER",
"data_type": "STRING",
"value": "1234567890"
}
]
}
]
}
] }
When I'm trying to index it I get the following error
{ "error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Can't merge a non object mapping [variables.value] with an object mapping [variables.value]"
}
],
"type": "illegal_argument_exception",
"reason": "Can't merge a non object mapping [variables.value] with an object mapping [variables.value]" }, "status": 400 }
Mapping
{ "example_data": {
"mappings": {
"data": {
"properties": {
"activity_id": {
"type": "text"
},
"name": {
"type": "text"
},
"process_name": {
"type": "text"
},
"process_version": {
"type": "integer"
}
"process_id": {
"type": "text"
},
"datetime": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
},
"username": {
"type": "text",
"analyzer": "greek"
},
"variables": {
"type": "nested",
"properties": {
"data_type": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"value": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}}}
When I remove the variable CUSTOMERS that contains the array, then It works properly because there are only json objects.
Is there a way to handle that? Thanks in advance