JSON to SQL Server 2016 missing rows from array - arrays

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.

Related

How to Break json object in a for each

How can one split the below json example by different email in a for each loop? So the end result is two completely separate entities keeping there own objects and arrays.
This result comes from a sql dump but the sql connector alters the output, so I've had to parse that output in a for each loop of its own even though there is no loop it's all in one line.
[
{
"Email": "Steve#gmail.com",
"Name": "Steve Larson",
"ID": "1111",
"Date": "2022-09-12",
"Address": "10 Chicken Place",
"Town": "Gatebody",
"Postcode": "xxx 1xx",
"Data": [
{
"Ref": "34546",
"Transaction_Date": "2018-11-29",
"Amount": 27.76,
"Balance": 27.76,
"Notes": "Beep1"
},
{
"Ref": "34546v2",
"Transaction_Date": "2018-12-24",
"Amount": 27.76,
"Balance": 27.76,
"Notes": "Beep2"
}
]
},
{
"Email": "innis#gmail.com",
"Name": "Innis Blitz",
"ID": "3456",
"Date": "2022-10-12",
"Address": "33 Snake Road",
"Town": "March",
"Postcode": "cxc 3cd",
"Data": [
{
"Ref": "078776701",
"Transaction_Date": "2021-08-27",
"Amount": 984.68,
"Balance": 984.68,
"Notes": "Yes please"
},
{
"Ref": "078776701v2",
"Transaction_Date": "2021-08-27",
"Amount": 98422.6,
"Balance": 98432.6,
"Notes": "Please not now"
}
]
}
]
Would like to do a for each so it splits the above like so. The idea then for my to load the result of the for each into a template that takes arrays.
{
"Email": "Steve#gmail.com",
"Name": "Steve Larson",
"ID": "1111",
"Date": "2022-09-12",
"Address": "10 Chicken Place",
"Town": "Gatebody",
"Postcode": "xxx 1xx",
"Data": [
{
"Ref": "34546",
"Transaction_Date": "2018-11-29",
"Amount": 27.76,
"Balance": 27.76,
"Notes": "Beep1"
},
{
"Ref": "34546v2",
"Transaction_Date": "2018-12-24",
"Amount": 27.76,
"Balance": 27.76,
"Notes": "Beep2"
}
]
}
{
"Email": "innis#gmail.com",
"Name": "Innis Blitz",
"ID": "3456",
"Date": "2022-10-12",
"Address": "33 Snake Road",
"Town": "March",
"Postcode": "cxc 3cd",
"Data": [
{
"Ref": "078776701",
"Transaction_Date": "2021-08-27",
"Amount": 984.68,
"Balance": 984.68,
"Notes": "Yes please"
},
{
"Ref": "078776701v2",
"Transaction_Date": "2021-08-27",
"Amount": 98422.6,
"Balance": 98432.6,
"Notes": "Please not now"
}
]
}
I have reproduced in my environment and got expected results and I followed below process:
I have initialized your input as below:
Then i added for each control and send the output of previous step as input as inside of foreach loop, i have added send email action.
Outputs:
I have got tow jsons in two seperate emails as above.

Reading JSON object data and how to filter?

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 most appropiate way to render unstructured data in react

I have a backend that returns unstructured data (another dev is responsible for the backend) and I have no idea how is the most appropiate way to render it, any ideas?.
What I have already tried is to render it with this library react-json-view but it's not very user friendly.
This is an example of the data I receive:
[
{
"conditions": [
"SIN_SALDO"
],
"typeItem": "MSISDN",
"createdDate": 1639677563,
"data": {
"msisdn": "571345543122"
},
"planName": "PRE_PAGO",
"backendName": "backofficeco",
"pk": "#CO#MSISDN#MI_tienda#backofficeco#cbb1efe963",
"country": "CO",
"resourceGroup": "MI_tienda"
},
{
"typeItem": "MSISDN",
"createdDate": 1644521244,
"data": {
"MSISDN": "asdfk"
},
"backendName": "adfs;fk",
"pk": "#CO#MSISDN#asdf#adfs;fk#7578238817",
"country": "CO",
"resourceGroup": "asdf"
},
{
"conditions": [
"SIN_SALDO"
],
"typeItem": "MSISDN",
"createdDate": 1644940771,
"data": {
"msisdn": "3007279930"
},
"planName": "POS_PAGO",
"backendName": "backofficeco",
"pk": "#CO#MSISDN#MI_tienda#backofficeco#25831ae7cf",
"country": "CO",
"resourceGroup": "MI_tienda"
},
{
"conditions": [
"SIN_SALDO"
],
"typeItem": "MSISDN",
"createdDate": 1644420646,
"data": {
"msisdn": "571345543122"
},
"planName": "adfasdf",
"backendName": "backofficeco",
"pk": "#CO#MSISDN#asdfasdf#backofficeco#c30d28f552",
"country": "CO",
"resourceGroup": "MI_tienda"
},
{
"typeItem": "MSISDN",
"createdDate": 1644525223,
"data": {
"MSISDN": "asdfasd"
},
"backendName": "asdfasdf",
"pk": "#CO#MSISDN#asdfasdf#asdfasdf#02ac5aa61b",
"country": "CO",
"resourceGroup": "asdfasdf"
},
{
"conditions": [
"adsfas"
],
"typeItem": "MSISDN",
"createdDate": 1646230406,
"data": {
"msisdn": "571345543122"
},
"planName": "adfasdf",
"backendName": "backofficeco",
"ttl": 1646835206,
"pk": "#CO#MSISDN#MI_tienda#backofficeco#cd40ee06af",
"country": "CO",
"resourceGroup": "adsfa"
}
]
Assuming you just want to render the list, you can try creating a map based on some key (maybe on 'pk') and pass it on, say to grid.

Parse this Json array and extract the value of text

Here is the full json that I want to parse and extract the text that has the value: The product is in second line 3rd row.
Can someone help?
"activities": [
{
"type": "message",
"id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"timestamp": "2019-07-01T15:18:56.8251462Z",
"serviceUrl": "XXXXXXXXXXXXXXXXXXXXXXXXX",
"channelId": "directline",
"from": {
"id": "user1"
},
"conversation": {
"id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
},
"text": "the milk"
},
{
"type": "message",
"id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"timestamp": "2019-07-01T15:18:57.6856172Z",
"localTimestamp": "2019-07-01T15:18:57.5099359+00:00",
"channelId": "directline",
"from": {
"id": "XXXXXX",
"name": "XXXXXX"
},
"conversation": {
"id": "XXXXXXXXXXXXXXXXXX"
},
"text": "The product is in second line 3rd row",
"attachments": [],
"entities": [],
"replyToId": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}
],
"watermark": "1"
}
You have specified that this is a full json you have placed in the question, But it is not full json you are missing something.
"activities":
[ //json array start from here
{
"type": "message",
"id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"timestamp": "2019-07-01T15:18:56.8251462Z",
"serviceUrl": "XXXXXXXXXXXXXXXXXXXXXXXXX",
"channelId": "directline",
"from": {
"id": "user1"
},
"conversation": {
"id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
},
"text": "the milk"
},
{
"type": "message",
"id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"timestamp": "2019-07-01T15:18:57.6856172Z",
"localTimestamp": "2019-07-01T15:18:57.5099359+00:00",
"channelId": "directline",
"from": {
"id": "XXXXXX",
"name": "XXXXXX"
},
"conversation": {
"id": "XXXXXXXXXXXXXXXXXX"
},
"text": "The product is in second line 3rd row",
"attachments": [],
"entities": [],
"replyToId": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}
], //json array ends here
these are extra lines
***"watermark": "1"
}***
if you want to use this array you need to add a '{' in very top line before
"activities": [
I am placing here a valid json now you can check it on Json parser used to parse json in objects
*Valid Json Here : *
{
"activities": [
{
"type": "message",
"id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"timestamp": "2019-07-01T15:18:56.8251462Z",
"serviceUrl": "XXXXXXXXXXXXXXXXXXXXXXXXX",
"channelId": "directline",
"from": {
"id": "user1"
},
"conversation": {
"id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
},
"text": "the milk"
},
{
"type": "message",
"id": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"timestamp": "2019-07-01T15:18:57.6856172Z",
"localTimestamp": "2019-07-01T15:18:57.5099359+00:00",
"channelId": "directline",
"from": {
"id": "XXXXXX",
"name": "XXXXXX"
},
"conversation": {
"id": "XXXXXXXXXXXXXXXXXX"
},
"text": "The product is in second line 3rd row",
"attachments": [],
"entities": [],
"replyToId": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}
],
"watermark": "1"
}

AngularJS ng-repeat display json

I'm having the hardest time figuring out how to display the following JSON file in my Angularjs repeat.
for the following JSON results, I thought I could simply display the title in an ng-repeat with the following:
<div ng-repeat="x in results">
{{x.data[0].title}}
</div>
But I'm not seeing results.
Here is the JSON:
{
"data": [
{
"id": 1,
"title": "Temp Title",
"description": "Temp Description",
"created_at": {
"date": "2016-03-15 07:10:17.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"updated_at": {
"date": "2016-03-15 07:10:17.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"user": {
"data": {
"id": 29,
"displayName": "chris.nakea",
"email": "chris.nakea#freshconsulting.com",
"join_date": 1458025279,
"profile": {
"data": {
"id": 29,
"displayName": "chris.nakea",
"avatar": null,
"firstName": null,
"lastName": null,
"bio": null,
"city": null,
"zipcode": null,
"state": null,
"country": null,
"latitude": null,
"longitude": null,
"avatars": {
"data": [
{
"id": "default_avatar.png",
"filename": "default_avatar.png",
"url": "https://cdn.band.dev/common/images/common/default_avatar.png",
"created_at": {
"date": "2016-03-15 00:00:00.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"images": {
"small": "https://cdn.band.dev/common/images/common/default_avatar_small.png",
"medium": "https://cdn.band.dev/common/images/common/default_avatar_medium.png",
"large": "https://cdn.band.dev/common/images/common/default_avatar_large.png"
}
}
]
},
"coverPhotos": {
"data": []
}
}
}
}
},
"category": {
"data": {
"id": 2,
"name": "Staff / Events",
"description": "Staff / Events",
"colorCode": "#242156",
"iconName": "icon-staff-events",
"iconCharacterCode": "c108"
}
},
"attachments": {
"data": [
{
"id": "1d3f96e2286c27ee599c9e49a0c33da0",
"filename": "man.jpg",
"url": "https://api.band.dev/v1/file/1d3f96e2286c27ee599c9e49a0c33da0",
"created_at": {
"date": "2016-03-15 07:10:17.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"images": {
"small": "https://api.band.dev/v1/file/50af58b3d52d8629e9f5c4d0dcdd5181",
"medium": "https://api.band.dev/v1/file/51535d38f7b3cd82313eac2414059d83",
"large": "https://api.band.dev/v1/file/a7be1dada18e4041cf48aea377cafa29"
}
}
]
}
},
{
"id": 2,
"title": "Temp Title",
"description": "Temp Description",
"created_at": {
"date": "2016-03-15 07:12:00.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"updated_at": {
"date": "2016-03-15 07:12:00.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"user": {
"data": {
"id": 29,
"displayName": "chris.nakea",
"email": "chris.nakea#freshconsulting.com",
"join_date": 1458025279,
"profile": {
"data": {
"id": 29,
"displayName": "chris.nakea",
"avatar": null,
"firstName": null,
"lastName": null,
"bio": null,
"city": null,
"zipcode": null,
"state": null,
"country": null,
"latitude": null,
"longitude": null,
"avatars": {
"data": [
{
"id": "default_avatar.png",
"filename": "default_avatar.png",
"url": "https://cdn.band.dev/common/images/common/default_avatar.png",
"created_at": {
"date": "2016-03-15 00:00:00.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"images": {
"small": "https://cdn.band.dev/common/images/common/default_avatar_small.png",
"medium": "https://cdn.band.dev/common/images/common/default_avatar_medium.png",
"large": "https://cdn.band.dev/common/images/common/default_avatar_large.png"
}
}
]
},
"coverPhotos": {
"data": []
}
}
}
}
},
"category": {
"data": {
"id": 2,
"name": "Staff / Events",
"description": "Staff / Events",
"colorCode": "#242156",
"iconName": "icon-staff-events",
"iconCharacterCode": "c108"
}
},
"attachments": {
"data": [
{
"id": "a93cf8df7b60686e7ca6884d0ce353c8",
"filename": "man2.jpg",
"url": "https://api.band.dev/v1/file/a93cf8df7b60686e7ca6884d0ce353c8",
"created_at": {
"date": "2016-03-15 07:12:00.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"images": {
"small": "https://api.band.dev/v1/file/cd04551395a355f4792fb85833156741",
"medium": "https://api.band.dev/v1/file/4ff543cd8f5055bfecd703dedaee6d87",
"large": "https://api.band.dev/v1/file/5cdd9a0c3650228e0b93f9c6cd1404df"
}
}
]
}
}
]
}
You can just remove the datap[0] part and get the output
<div ng-repeat="x in results.data">
{{x.title}}
</div>
Output:
Temp Title
Temp Title
if you want to filter then you can do it by
<div ng-repeat="x in results.data | filter: { id: '1' }">
{{x.title}}
</div>
Output:
Temp Title
<div ng-repeat="item in data">{{item.title}}</div>
And in your controller, bind the json to the scope.
$scope.data = jsonData.data;
Here's a fiddle for you - jsFiddle
<div ng-repeat="x in results.data">
{{x.title}}
</div>
https://jsfiddle.net/nvqf8oo7/6/
Thank you all for responding. I finally figured out that the reason I wasn't seeing anything was because I am using ui.bootstrap's modal and I was out of scope.
I resolved this by moving the ng-repeat out of the modal, but I could have also tried to work with the modal scope itself.

Resources