How can I correct this Jolt Transformation? - arrays

This is an input that needs to be transformed using Jolt Transformation to obtain the expected output.
I am trying to write a jolt transformation for the below input.
but It's not matched with the expected output.
My Input:
{
"ConsolidatedList": [
{
"AliasType": "AKA",
"AliasTypeName": "AKA",
"BusinessRegNumber": {
"nil": null
},
"nil": null,
"Country": null,
"CountryOfBirth": "Syria",
"CurrentOwners": {
"nil": null
},
"DateListed": "2021-03-15T00:00:00",
"DateListedDay": 15,
"DateListedMonth": 3,
"DateListedYear": 2021,
"DateOfBirth": "01/09/1975",
"DateOfBirthId": 4751,
"DayOfBirth": 1,
"EmailAddress": {
"nil": null
},
"FCOId": "SYR0377",
"FlagOfVessel": {
"nil": null
},
"FullAddress": null,
"FullName": " Al Shebil Luna ",
"FurtherIdentifiyingInformation": {
"nil": null
},
"Gender": "Female",
"GroupID": 14070,
"GroupStatus": "Asset Freeze Targets",
"GroupTypeDescription": "Individual",
"GrpStatus": "A",
"HIN": {
"nil": null
},
"ID": 33233,
"IMONumber": {
"nil": null
},
"LastUpdated": "2021-03-15T00:00:00",
"LastUpdatedDay": 15,
"LastUpdatedMonth": 3,
"LastUpdatedYear": 2021,
"LengthOfVessel": {
"nil": null
},
"ListingType": "UK autonomous",
"MonthOfBirth": 9,
"Name6": "Al Shebil",
"NameTitle": null,
"NationalIdNumber": {
"nil": null
},
"Nationality": "Syria",
"OrgType": {
"nil": null
},
"OtherInformation": "MapRecord[{{http://www.w3.org/2001/XMLSchema-instance}nil=true}]",
"ParentCompany": {
"nil": null
},
"PassportDetails": "MapRecord[{{http://www.w3.org/2001/XMLSchema-instance}nil=true}]",
"PhoneNumber": {
"nil": null
},
"Position": "Media Adviser to President Assad",
"PostCode": null,
"PreviousFlags": {
"nil": null
},
"PreviousOwners": {
"nil": null
},
"RegimeName": "Syria",
"Subsidiaries": {
"nil": null
},
"TonnageOfVessel": {
"nil": null
},
"TownOfBirth": "Suweida",
"TypeOfVessel": {
"nil": null
},
"UKStatementOfReasons": "Adviser to President Assad and a prominent member of his inner circle. As Media Adviser to the President she supports the Syrian regime, which relies on disinformation and a lack of media freedom to repress the civilian population. She is also associated with the Syrian regime through her role as an adviser.\n",
"Website": {
"nil": null
},
"YearBuilt": {
"nil": null
},
"YearOfBirth": 1975,
"address1": null,
"address2": null,
"address3": null,
"address4": null,
"address5": null,
"address6": null,
"name1": "Luna",
"name2": null,
"name3": null,
"name4": null,
"name5": null
},
{
"AliasType": "AKA",
"AliasTypeName": "AKA",
"BusinessRegNumber": {
"nil": null
},
"nil": null,
"Country": null,
"CountryOfBirth": "Syria",
"CurrentOwners": {
"nil": null
},
"DateListed": "2021-03-15T00:00:00",
"DateListedDay": 15,
"DateListedMonth": 3,
"DateListedYear": 2021,
"DateOfBirth": "01/09/1975",
"DateOfBirthId": 4751,
"DayOfBirth": 1,
"EmailAddress": {
"nil": null
},
"FCOId": "SYR0377",
"FlagOfVessel": {
"nil": null
},
"FullAddress": null,
"FullName": " Al Shebil Luna ",
"FurtherIdentifiyingInformation": {
"nil": null
},
"Gender": "Female",
"GroupID": 14070,
"GroupStatus": "Asset Freeze Targets",
"GroupTypeDescription": "Individual",
"GrpStatus": "A",
"HIN": {
"nil": null
},
"ID": 33233,
"IMONumber": {
"nil": null
},
"LastUpdated": "2021-03-15T00:00:00",
"LastUpdatedDay": 15,
"LastUpdatedMonth": 3,
"LastUpdatedYear": 2021,
"LengthOfVessel": {
"nil": null
},
"ListingType": "UK autonomous",
"MonthOfBirth": 9,
"Name6": "Al Shebil",
"NameTitle": null,
"NationalIdNumber": {
"nil": null
},
"Nationality": "Syria",
"OrgType": {
"nil": null
},
"OtherInformation": "MapRecord[{{http://www.w3.org/2001/XMLSchema-instance}nil=true}]",
"ParentCompany": {
"nil": null
},
"PassportDetails": "MapRecord[{{http://www.w3.org/2001/XMLSchema-instance}nil=true}]",
"PhoneNumber": {
"nil": null
},
"Position": "Media Adviser to President Assad",
"PostCode": null,
"PreviousFlags": {
"nil": null
},
"PreviousOwners": {
"nil": null
},
"RegimeName": "Syria",
"Subsidiaries": {
"nil": null
},
"TonnageOfVessel": {
"nil": null
},
"TownOfBirth": "Suweida",
"TypeOfVessel": {
"nil": null
},
"UKStatementOfReasons": "Adviser to President Assad and a prominent member of his inner circle. As Media Adviser to the President she supports the Syrian regime, which relies on disinformation and a lack of media freedom to repress the civilian population. She is also associated with the Syrian regime through her role as an adviser.\n",
"Website": {
"nil": null
},
"YearBuilt": {
"nil": null
},
"YearOfBirth": 1975,
"address1": null,
"address2": null,
"address3": null,
"address4": null,
"address5": null,
"address6": null,
"name1": "Hassan",
"name2": "Muh",
"name3": "Cane",
"name4": null,
"name5": null
}
]
}
And the expected output is -
{
"Count": "2", // Counter for the number of records
"LastUpdated": "08/03/2020 12:00:00",
"RecordType": [
"Entity",
"Individual",
"Vessel"
],
"Pages": "1",
"Records": [
{
"_id": "1", // Counter
"AdditionalInformation": "Other Information: (UK Sanctions List Ref):AQD0081 (UN Ref):QDe.014 (Further Identifiying Information):Headed by Abdelmalek Droukdel (QDi.232).Zone of operation includes Algeria and parts of Mali, Mauritania, Niger, Tunisia and Morocco.Review pursuant to Security Council resolution 1822 (2008) was concluded on 21 Jun.2010.INTERPOL-UN Security Council Special Notice web link: https://www.interpol.int/en/notice/search/une/5278467; Listed On: 10/10/2001; Last Updated: 12/31/2020; Group ID: 7247",
"RecordType": "Entity",
"Names": [
{
"_id": "1", //counter
"OtherName": "THE ORGANIZATION OF AL-QAIDA IN THE ISLAMIC MAGHREB",
"UnparsedName": "",
"FirstName": "",
"LastName": "",
"NameType": "Primary"
},
{
"_id": "2",
"OtherName": "AL QAIDA AU MAGHREB ISLAMIQUE (AQMI)",
"UnparsedName": "",
"FirstName": "",
"LastName": "",
"NameType": "Alias"
},
{
"_id": "3",
"OtherName": "AQIM",
"UnparsedName": "",
"FirstName": "",
"LastName": "",
"NameType": "Alias"
},
{
"_id": "4",
"OtherName": "LE GROUPE SALAFISTE POUR LA PREDICATION ET LE COMBAT (GSPC)",
"UnparsedName": "",
"FirstName": "",
"LastName": "",
"NameType": "Formerly Known As"
},
{
"_id": "5",
"OtherName": "SALAFIST GROUP FOR CALL AND COMBAT",
"UnparsedName": "",
"FirstName": "",
"LastName": "",
"NameType": "Formerly Known As"
}
],
"Addresses": [
{
"_id": "1",
"PostalCode": "",
"Street": "",
"City": "",
"StateProvince": "",
"Country": {
"Name": "Algeria",
"RelationType": "Address"
}
},
{
"_id": "2",
"PostalCode": "",
"Street": "",
"City": "",
"StateProvince": "",
"Country": {
"Name": "Mali",
"RelationType": "Address"
}
},
{
"_id": "3",
"PostalCode": "",
"Street": "",
"City": "",
"StateProvince": "",
"Country": {
"Name": "Mauritania",
"RelationType": "Address"
}
},
{
"_id": "4",
"PostalCode": "",
"Street": "",
"City": "",
"StateProvince": "",
"Country": {
"Name": "Morocco",
"RelationType": "Address"
}
},
{
"_id": "5",
"PostalCode": "",
"Street": "",
"City": "",
"StateProvince": "",
"Country": {
"Name": "Niger",
"RelationType": "Address"
}
},
{
"_id": "6",
"PostalCode": "",
"Street": "",
"City": "",
"StateProvince": "",
"Country": {
"Name": "Tunisia",
"RelationType": "Address"
}
}
],
"Sanctions": [
{
"_id": "1",
"Sanction": "HM Treasury Al-Qaida Sanction",
"ExpirationDate": "",
"SanctionDate": ""
}
]
},
{
"_id": "2",
"AdditionalInformation": "Other Information: (UK Sanctions List Ref):AFG0110 (UN Ref): TAi.142 (Further Identifiying Information):Review pursuant to Security Council resolution 1822 (2008) was concluded on 29 Jul. 2010. INTERPOL-UN Security Council Special Notice web link: https://www.interpol.int/en/How-we-work/Notices/View-UN-Notices-Individuals click here.; Listed On: 02/23/2001; Last Updated: 2/1/2021; Group ID: 6895",
"RecordType": "Person",
"Names": [
{
"_id": "1",
"OtherName": "",
"UnparsedName": "",
"FirstName": "Abdul Hai Hazem",
"LastName": "ABDUL QADER",
"NameType": "Primary"
},
{
"_id": "2",
"OtherName": "",
"UnparsedName": "",
"FirstName": "Abdul Hai",
"LastName": "HAZEM",
"NameType": "Alias"
}
],
"Identifiers": [
{
"_id": "1",
"IDValue": "1971",
"IDType": "Date Of Birth"
},
{
"_id": "2",
"IDValue": "Pashawal Yargatoo village, Andar District, Ghazni Province, Afghanistan",
"IDType": "Place Of Birth"
},
{
"_id": "3",
"IDValue": "D 0001203 (Afghan)",
"IDType": "Passport"
}
],
"Addresses": [
{
"_id": "1",
"PostalCode": "",
"Street": "",
"City": "",
"StateProvince": "Kabul Province",
"Country": {
"Name": "Afghanistan",
"RelationType": "Address"
}
},
{
"_id": "2",
"PostalCode": "",
"Street": "",
"City": "Kabul City",
"StateProvince": "Kabul Province",
"Country": {
"Name": "",
"RelationType": "Address"
}
},
{
"_id": "3",
"PostalCode": "",
"Street": "",
"City": "",
"StateProvince": "",
"Country": {
"Name": "Afghan",
"RelationType": "Nationality"
}
}
],
"Sanctions": [
{
"_id": "1",
"Sanction": "HM Treasury Afghanistan Sanction",
"ExpirationDate": "",
"SanctionDate": ""
}
]
}
]
}
My spec is -
[
{
"operation" : "shift",
"spec": {
"ConsolidatedList": {
"*": {
"GroupTypeDescription": "RecordType",
"LastUpdated": "LastUpdated",
"UKStatementOfReasons": "Records.AdditionalInformation",
"Name6": "Records.Names.[&1].Other Name",
"name3": "Records.Names.[&1].UnparsedName",
"name1": "Records.Names.[&1].FirstName",
"name2": "Records.Names.[&1].LastName",
"AliasType": "Records.Names.[&1].NameType",
"PostCode": "Records.Address.[&1].PostalCode",
"address2": "Records.Address.[&1].Street",
"address6": "Records.Address.[&1].City",
"Country": "Records.Address.[&1].StateProvince",
"CountryOfBirth": "Records.Address.[&1].Country.Name"
}
}
}
},
{
"operation": "modify-overwrite-beta",
"spec" : {
"Count": "size(1,Records)",
"Pages": "1"
}
}
]
The spec is not transforming as expected output.

Related

How to create a JSON structure in ReactJS

I have a use-case to create a JSON structure in React in order to POST an API request. The JSON structure body contains objects and arrays.
Please let me know how to create it in ReactJS.
Below is the sample JSON structure that needs to be created using ReactJS:-
{
"transactionAmount": {
"currency": "INR",
"value": 1220.38
},
"transactionDate": "2020-05-18T00:00:00Z",
"tripData": {
"agencyBooked": false,
"legs": [
{
"endLocation": {
"countryCode": "IN",
"city": "Delhi",
"name": "Indira Gandhi International"
},
"startDate": "2020-05-22",
"startTime": "08:00",
"returnLeg": false,
"startLocation": {
"countryCode": "US",
"city": "San Francisco",
"name": "San Francisco International"
},
"endTime": "21:00",
"endDate": "2020-05-22",
"startLocationDetail": "none"
},
{
"endLocation": {
"countryCode": "US",
"city": "San Francisco",
"name": "San Francisco International"
},
"returnLeg": true,
"startDate": "2020-05-24",
"startLocation": {
"countryCode": "IN",
"city": "Delhi",
"name": "Indira Gandhi International"
},
"startTime": "17:00"
}
],
"segmentType": {
"category": "REQ_SEG_AIRFR",
"code": "AIRFR"
},
"selfBooked": false,
"tripType": "ROUND_TRIP"
}
}
You can simply make a JSON format like this.
const dummyObject = {
name: 'Dummy',
age: 22,
about: {
hobbies: ['soccer']
},
works: true
}

JSON to SQL Server 2016 missing rows from array

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.

How to fetch array of array data in angular 2?

How to fetch array of array data in angular 2.
My json data is as follows,
[[{
"pk_emp_id":5,
"tenant_id":"Zone1",
"location_id":1,
"emp_number":"sk44",
"prefix":"",
"first_name":"qqqqq",
"middle_name":"www",
"last_name":"eeee",
"display_name":"qqqq",
"full_name":"qqq qqqq",
"email":"qqqq#gmail.com",
"gender":"Female",
"emp_type_id":2,
"date_of_hire":191000,
"date_of_birth":null,
"manager_id":7,
"phone_number":"9877654",
"position":"SE",
"responsibility":"",
"notes":"",
"contracted":"0",
"street":"vidyanagar",
"state":"Karnataka",
"city":"hubli",
"zip_code":"9898",
"dob":-19800000,
"ssn":"",
"deleted":0
},{
"pk_empt_id":2,
"empt_tenant_id":"2",
"***empt_name***":"temporary",
"deleted":0
}]]
How can I fetch empt_name in datatable(row data)?
let dummyArr = [
[{
"pk_emp_id": 5,
"tenant_id": "Zone1",
"location_id": 1,
"emp_number": "sk44",
"prefix": "",
"first_name": "qqqqq",
"middle_name": "www",
"last_name": "eeee",
"display_name": "qqqq",
"full_name": "qqq qqqq",
"email": "qqqq#gmail.com",
"gender": "Female",
"emp_type_id": 2,
"date_of_hire": 191000,
"date_of_birth": null,
"manager_id": 7,
"phone_number": "9877654",
"position": "SE",
"responsibility": "",
"notes": "",
"contracted": "0",
"street": "vidyanagar",
"state": "Karnataka",
"city": "hubli",
"zip_code": "9898",
"dob": -19800000,
"ssn": "",
"deleted": 0
}, {
"pk_empt_id": 2,
"empt_tenant_id": "2",
"***empt_name***": "temporary",
"deleted": 0
}]
];
dummyArr.forEach(element =>{
element.forEach(element2=>{
console.log(element2)
})
});
I believe you have exposed a GET method in your web api
In Angular using HTTP service
this.http.get("").subscribe(result => {
conosle.log(result[1].empt_name) });
You can take it in an array and read it like this:
x = [
[{
"pk_emp_id": 5,
"tenant_id": "Zone1",
"location_id": 1,
"emp_number": "sk44",
"prefix": "",
"first_name": "qqqqq",
"middle_name": "www",
"last_name": "eeee",
"display_name": "qqqq",
"full_name": "qqq qqqq",
"email": "qqqq#gmail.com",
"gender": "Female",
"emp_type_id": 2,
"date_of_hire": 191000,
"date_of_birth": null,
"manager_id": 7,
"phone_number": "9877654",
"position": "SE",
"responsibility": "",
"notes": "",
"contracted": "0",
"street": "vidyanagar",
"state": "Karnataka",
"city": "hubli",
"zip_code": "9898",
"dob": -19800000,
"ssn": "",
"deleted": 0
}, {
"pk_empt_id": 2,
"empt_tenant_id": "2",
"***empt_name***": "temporary",
"deleted": 0
}]
]
$('#a').text(x[0][1]['***empt_name***'])
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<span id='a'>sadsad </span>
This is just Javascript object manipulation.
You can do something like :
outerArray.forEach(innerArray =>{
if(innerArray.length){
innerArray.forEach(element =>{
//do somthing here with element.empt_name
console.log(element.empt_name);
});
}
})

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.

extjs nested json

Getting conflicting information from various places on whether or not nested json is available in extjs. NB using Sencha Architect which may be complicating things...
I have a client json object being returnd via a store/ajax proxy. I can not access anything beyond the first level.
JSON looks like this:
{
"client": {
"0": {
"id": "12345",
"type_id": "3",
"association_id": "0",
"is_active": "1",
"manager_id": "2",
"business_name": null,
"has_payroll": "0",
"business_proprietor_contact_id": null,
"date_created": "1358893243",
"date_modified": "1358893243"
},
"contacts": [
{
"id": "1",
"client_id": "12345",
"contact_id": "1",
"is_primary": "0",
"display_priority": "0",
"relationship": "Client",
"friendly_name": "Homer",
"contact": [
{
"id": "1",
"surname": "Mr.",
"first_name": "Homer",
"middle_name": "J",
"last_name": "Simpson",
"client_id": "12345",
"date_created": "1356038714",
"date_modified": null
},
{
"addresses": [
{
"id": "1",
"contact_id": "1",
"address_id": "16",
"is_mailing_address": "0",
"is_primary_address": "0",
"display_priority": "0",
"address": {
"0": {
"id": "16",
"address": "5 Dirt Rd",
"address2": "",
"city": "TAXMASTER",
"state": "NY",
"zip_code": "454545",
"country": "USA",
"other": null,
"phone": null,
"fax": null,
"display_priority": null,
"is_mailing_address": "1"
},
"data": [
{
"id": "10",
"label": "Phone",
"value": "BUT WHO WAS",
"date_created": "1356104685",
"date_modified": "1357142782",
"user_id": null,
"display_priority": null,
"client_id": null,
"contact_id": null,
"account_id": null,
"business_id": null,
"address_id": "16",
"is_deleted": "0"
},
{
"id": "14",
"label": "Fax",
"value": "simile",
"date_created": "1356557379",
"date_modified": "1357142782",
"user_id": null,
"display_priority": null,
"client_id": null,
"contact_id": null,
"account_id": null,
"business_id": null,
"address_id": "16",
"is_deleted": "0"
},
{
"id": "17",
"label": "Also Known as:",
"value": "DUDE",
"date_created": "1357141357",
"date_modified": "1357142782",
"user_id": null,
"display_priority": null,
"client_id": null,
"contact_id": null,
"account_id": null,
"business_id": null,
"address_id": "16",
"is_deleted": "0"
}
]
}
},
{
"id": "6",
"contact_id": "1",
"address_id": "26",
"is_mailing_address": "0",
"is_primary_address": "0",
"display_priority": "0",
"address": {
"0": {
"id": "26",
"address": "1 Lift Road",
"address2": "",
"city": "Tony Beach",
"state": "KS",
"zip_code": "15151",
"country": "USA",
"other": null,
"phone": null,
"fax": null,
"display_priority": null,
"is_mailing_address": "0"
},
"data": [
{
"id": "18",
"label": "Phone:",
"value": "cool phone number",
"date_created": "1357141527",
"date_modified": "1357141527",
"user_id": null,
"display_priority": null,
"client_id": null,
"contact_id": null,
"account_id": null,
"business_id": null,
"address_id": "26",
"is_deleted": "0"
},
{
"id": "19",
"label": "Note:",
"value": "cool note",
"date_created": "1357141527",
"date_modified": "1357141527",
"user_id": null,
"display_priority": null,
"client_id": null,
"contact_id": null,
"account_id": null,
"business_id": null,
"address_id": "26",
"is_deleted": "0"
}
]
}
},
],
"data": [
{
"id": "1",
"label": "asdf",
"value": "dfdfefefefef",
"date_created": "1356038714",
"date_modified": "1356040822",
"user_id": "2",
"display_priority": "0",
"client_id": null,
"contact_id": "1",
"account_id": null,
"business_id": null,
"address_id": null,
"is_deleted": "0"
},
{
"id": "2",
"label": "asfd",
"value": "152151",
"date_created": "1356038714",
"date_modified": "1356040822",
"user_id": null,
"display_priority": "2",
"client_id": null,
"contact_id": "1",
"account_id": null,
"business_id": null,
"address_id": null,
"is_deleted": "0"
},
]
}
]
},
{
"id": "7",
"client_id": "12345",
"contact_id": "11",
"is_primary": "0",
"display_priority": "0",
"relationship": "None",
"friendly_name": "Mary Jane",
"contact": {
"0": {
"id": "11",
"surname": "",
"first_name": "Mary Jane",
"middle_name": "",
"last_name": "Simpson",
"client_id": null,
"date_created": "1357145795",
"date_modified": null
},
"7": {
"addresses": [
{
"id": "11",
"contact_id": "11",
"address_id": "33",
"is_mailing_address": "0",
"is_primary_address": "0",
"display_priority": "0",
"address": {
"0": {
"id": "33",
"address": "33 Street",
"address2": "",
"city": "NY",
"state": "NY",
"zip_code": "06830",
"country": "USA",
"other": null,
"phone": null,
"fax": null,
"display_priority": null,
"is_mailing_address": "0"
},
"data": [
{
"id": "31",
"label": "Fax:",
"value": "asdfasdf",
"date_created": "1357145905",
"date_modified": "1357145939",
"user_id": null,
"display_priority": null,
"client_id": null,
"contact_id": null,
"account_id": null,
"business_id": null,
"address_id": "33",
"is_deleted": "0"
},
{
"id": "32",
"label": "Fax:",
"value": "sadfsadf",
"date_created": "1357145905",
"date_modified": "1357145905",
"user_id": null,
"display_priority": null,
"client_id": null,
"contact_id": null,
"account_id": null,
"business_id": null,
"address_id": "33",
"is_deleted": "0"
}
]
}
}
],
"data": [
{
"id": "29",
"label": "Phone:",
"value": "asdfsadf",
"date_created": "1357145833",
"date_modified": "1357145833",
"user_id": "2",
"display_priority": null,
"client_id": null,
"contact_id": "11",
"account_id": null,
"business_id": null,
"address_id": null,
"is_deleted": "0"
},
{
"id": "30",
"label": "Email:",
"value": "dsfgdsfg",
"date_created": "1357145855",
"date_modified": "1357145855",
"user_id": "2",
"display_priority": null,
"client_id": null,
"contact_id": "11",
"account_id": null,
"business_id": null,
"address_id": null,
"is_deleted": "0"
}
]
}
}
}
],
"notes": [
{
"id": "5",
"client_id": "12345",
"label": "This is a HomerHomer Note",
"value": "This is from Homer's Dashboard Notes.",
"contact_id": null,
"address_id": null,
"account_id": null,
"account_data_id": null,
"account_credential_id": null,
"payment_id": null,
"contact_log_id": null,
"user_id": "2",
"bill_id": null,
"is_deleted": "0",
"date_created": "1357148256",
"date_modified": "1357148256"
}
]
}
}
According to https://stackoverflow.com/a/8318589/183254 nested JSON isn't available. According to https://stackoverflow.com/a/5604594/183254 it is available, but has to be in a certain format.
I did a little test based on the API docs format:
{
results: 2000,
rows: [
{ id: 1, firstname: 'Bill', occupation: 'Gardener', cool: {neat: 'wow'} },
{ id: 2, firstname: 'Ben' , occupation: 'Horticulturalist' },
]
}
with this coming in, I can call everything from a tpl. In particular, cool.neat prints wow. However, changing cool to cool:[{neat:'wow}] breaks. So it seems nested json partially works -- likely only partially because I'm doing something wrong.
My thinking was that it'd make sense to do a single request to the api and gather all the needed info, parse it, and send it out to components rather than creating proxies for every group of data that is needed. I may be wrong...
Along with needed guidance/facepunches I have 2 questions:
1) Is it possible/practical to try and do what I'm doing? i.e. trying to use a single request to gather the data for multiple components?
2) Is there a way to debug data from tpl?
This is extjs 4.1 via Sencha Architect
Thanks.
I had this same issue. The only way I could get around it (I tried mapping and several other solutions) is basically have a main store and substores. Get the information from ajax and bring it into the main store. Have a "load" listener and when it loads, check to see if the inforamtion needs to be passed to the other store(s).
Set all the substores autoload property to false and never load them.
i.e:
load: function(t,records,successful,eOpts) {
var substores [{store: nameOfStore, root: rootPropInTheJson},
{store...etc...etc..];
for (var i = 0; i < substores.length; i++) {
if (pathtoroot* != undefined) {
substores[i].store.add(pathtojsonroot)
}
}
}
At least, this is what I think you meant. If this is what you meant, then yes, I found it practical, and I don't know the answer to the second question.

Resources