How to print USD Price from My JSON? - arrays

I have data like this
[
{
"id": "ethereum",
"name": "Ethereum",
"symbol": "ETH",
"rank": "2",
"price_usd": "449.935",
"price_btc": "0.0574132",
"24h_volume_usd": "1632850000.0",
"market_cap_usd": "44300619222.0",
"available_supply": "98460042.0",
"total_supply": "98460042.0",
"max_supply": null,
"percent_change_1h": "0.11",
"percent_change_24h": "-2.69",
"percent_change_7d": "-21.25",
"last_updated": "1522211054"
}
]
Anyone can help me to print USD Price? Like this...
USD Price: 449.935

I think you're just looking for data[0].price_usd?
var data = [
{
"id": "ethereum",
"name": "Ethereum",
"symbol": "ETH",
"rank": "2",
"price_usd": "449.935",
"price_btc": "0.0574132",
"24h_volume_usd": "1632850000.0",
"market_cap_usd": "44300619222.0",
"available_supply": "98460042.0",
"total_supply": "98460042.0",
"max_supply": null,
"percent_change_1h": "0.11",
"percent_change_24h": "-2.69",
"percent_change_7d": "-21.25",
"last_updated": "1522211054"
}];
console.log('USD Price: ' + data[0].price_usd);

Related

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.

Azure maps autocomplete - country and city only

I am writing an autocomplete service and want to get only country and city calling a Microsoft Azure service - with no addresses and POI or such.
I currently found Address Search where I would need to call https://atlas.microsoft.com/search/address, but it returns addresses, not cities and countries - which leads to many duplicates.
Plus, If I need to have a fixed number of auto complete options - say, 15 - it is going to require multiple calls to the service until I have all 15. On top of that, I will never know if there are more results for a typed partial country/city combination or not.
I don't want to use a fixed list as it needs maintenance.
I would not want to use another data provider for now, if it is possible to achieve with Azure.
This isn't supported yet, but is planned for the future. The closest that could be done now would be to use the https://learn.microsoft.com/en-us/rest/api/maps/search/getsearchaddressstructured service but it requires a country code to be specified, so you would only get cities for the specified country. For example, passing in new as the municipality as done in the following query:
https://atlas.microsoft.com/search/address/structured/json?api-version=1&municipality=new&countryCode=US&subscription-key=<Your_Key>
will return the following city results:
New York
New Orleans
New Braunfels
New Port Richey
New Bern
New Haven
New Iberia
New Castle
New Bedford
New Albany
Here is the raw response
{
"summary": {
"query": "new",
"queryType": "NON_NEAR",
"queryTime": 23,
"numResults": 10,
"offset": 0,
"totalResults": 998,
"fuzzyLevel": 1
},
"results": [
{
"type": "Geography",
"id": "US/GEO/p0/1167",
"score": 2.6649377346,
"entityType": "Municipality",
"address": {
"municipality": "New York",
"countrySubdivision": "NY",
"countrySubdivisionName": "New York",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New York, NY"
},
"position": {
"lat": 40.71305,
"lon": -74.00723
},
"viewport": {
"topLeftPoint": {
"lat": 40.9175,
"lon": -74.25564
},
"btmRightPoint": {
"lat": 40.49587,
"lon": -73.70027
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 40.9175,
"lon": -74.25564
},
"btmRightPoint": {
"lat": 40.49587,
"lon": -73.70027
}
},
"dataSources": {
"geometry": {
"id": "d49d86a4-0f4b-45f2-b607-31a84d02af00"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/90711",
"score": 2.5113995075,
"entityType": "Municipality",
"address": {
"municipality": "New Orleans",
"countrySecondarySubdivision": "Orleans",
"countrySubdivision": "LA",
"countrySubdivisionName": "Louisiana",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New Orleans, LA"
},
"position": {
"lat": 29.95176,
"lon": -90.07462
},
"viewport": {
"topLeftPoint": {
"lat": 30.21747,
"lon": -90.24051
},
"btmRightPoint": {
"lat": 29.86582,
"lon": -89.62506
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 30.21747,
"lon": -90.24051
},
"btmRightPoint": {
"lat": 29.86582,
"lon": -89.62506
}
},
"dataSources": {
"geometry": {
"id": "0000554c-4100-3c00-0000-0000596a7628"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/103135",
"score": 2.4384012222,
"entityType": "Municipality",
"address": {
"municipality": "New Braunfels",
"countrySubdivision": "TX",
"countrySubdivisionName": "Texas",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New Braunfels, TX"
},
"position": {
"lat": 29.70988,
"lon": -98.11973
},
"viewport": {
"topLeftPoint": {
"lat": 29.91293,
"lon": -98.34627
},
"btmRightPoint": {
"lat": 29.59298,
"lon": -97.9908
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 29.91293,
"lon": -98.34627
},
"btmRightPoint": {
"lat": 29.59298,
"lon": -97.9908
}
},
"dataSources": {
"geometry": {
"id": "9d7bf985-115b-423a-979a-97cc093c3166"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/23041",
"score": 2.4345231056,
"entityType": "Municipality",
"address": {
"municipality": "New Port Richey",
"countrySecondarySubdivision": "Pasco",
"countrySubdivision": "FL",
"countrySubdivisionName": "Florida",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New Port Richey, FL"
},
"position": {
"lat": 28.2502,
"lon": -82.71408
},
"viewport": {
"topLeftPoint": {
"lat": 28.33939,
"lon": -82.76461
},
"btmRightPoint": {
"lat": 28.17319,
"lon": -82.57478
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 28.33939,
"lon": -82.76461
},
"btmRightPoint": {
"lat": 28.17319,
"lon": -82.57478
}
},
"dataSources": {
"geometry": {
"id": "00005546-3300-3c00-0000-000059a7e5e6"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/27115",
"score": 2.414732933,
"entityType": "Municipality",
"address": {
"municipality": "New Bern",
"countrySecondarySubdivision": "Craven",
"countrySubdivision": "NC",
"countrySubdivisionName": "North Carolina",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New Bern, NC"
},
"position": {
"lat": 35.10832,
"lon": -77.04612
},
"viewport": {
"topLeftPoint": {
"lat": 35.28085,
"lon": -77.26051
},
"btmRightPoint": {
"lat": 34.90304,
"lon": -76.83165
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 35.28085,
"lon": -77.26051
},
"btmRightPoint": {
"lat": 34.90304,
"lon": -76.83165
}
},
"dataSources": {
"geometry": {
"id": "00004e43-3300-3c00-0000-0000596be1d9"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/60622",
"score": 2.4027762413,
"entityType": "Municipality",
"address": {
"municipality": "New Haven",
"countrySecondarySubdivision": "New Haven",
"countrySubdivision": "CT",
"countrySubdivisionName": "Connecticut",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New Haven, CT"
},
"position": {
"lat": 41.30825,
"lon": -72.92416
},
"viewport": {
"topLeftPoint": {
"lat": 41.35038,
"lon": -72.99807
},
"btmRightPoint": {
"lat": 41.2464,
"lon": -72.81773
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 41.35038,
"lon": -72.99807
},
"btmRightPoint": {
"lat": 41.2464,
"lon": -72.81773
}
},
"dataSources": {
"geometry": {
"id": "00005543-5400-3c00-0000-0000596911a2"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/90802",
"score": 2.4020097256,
"entityType": "Municipality",
"address": {
"municipality": "New Iberia",
"countrySecondarySubdivision": "Iberia",
"countrySubdivision": "LA",
"countrySubdivisionName": "Louisiana",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New Iberia, LA"
},
"position": {
"lat": 30.00256,
"lon": -91.81698
},
"viewport": {
"topLeftPoint": {
"lat": 30.12129,
"lon": -91.9944
},
"btmRightPoint": {
"lat": 29.73782,
"lon": -91.65921
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 30.12129,
"lon": -91.9944
},
"btmRightPoint": {
"lat": 29.73782,
"lon": -91.65921
}
},
"dataSources": {
"geometry": {
"id": "0000554c-4100-3c00-0000-00005968eae5"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/61589",
"score": 2.3937933445,
"entityType": "Municipality",
"address": {
"municipality": "New Castle",
"countrySecondarySubdivision": "New Castle",
"countrySubdivision": "DE",
"countrySubdivisionName": "Delaware",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New Castle, DE"
},
"position": {
"lat": 39.66066,
"lon": -75.56184
},
"viewport": {
"topLeftPoint": {
"lat": 39.7245,
"lon": -75.66496
},
"btmRightPoint": {
"lat": 39.55219,
"lon": -75.50945
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 39.7245,
"lon": -75.66496
},
"btmRightPoint": {
"lat": 39.55219,
"lon": -75.50945
}
},
"dataSources": {
"geometry": {
"id": "00005544-4500-3c00-0000-000059685073"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/36482",
"score": 2.3928732872,
"entityType": "Municipality",
"address": {
"municipality": "New Bedford",
"countrySecondarySubdivision": "Bristol",
"countrySubdivision": "MA",
"countrySubdivisionName": "Massachusetts",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New Bedford, MA"
},
"position": {
"lat": 41.63405,
"lon": -70.92766
},
"viewport": {
"topLeftPoint": {
"lat": 41.74525,
"lon": -70.97843
},
"btmRightPoint": {
"lat": 41.58185,
"lon": -70.87872
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 41.74525,
"lon": -70.97843
},
"btmRightPoint": {
"lat": 41.58185,
"lon": -70.87872
}
},
"dataSources": {
"geometry": {
"id": "0000554d-4100-3c00-0000-00005969fc6d"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/12185",
"score": 2.3897461891,
"entityType": "Municipality",
"address": {
"municipality": "New Albany",
"countrySecondarySubdivision": "Floyd",
"countrySubdivision": "IN",
"countrySubdivisionName": "Indiana",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "New Albany, IN"
},
"position": {
"lat": 38.28351,
"lon": -85.823
},
"viewport": {
"topLeftPoint": {
"lat": 38.40435,
"lon": -85.8853
},
"btmRightPoint": {
"lat": 38.22944,
"lon": -85.76089
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 38.40435,
"lon": -85.8853
},
"btmRightPoint": {
"lat": 38.22944,
"lon": -85.76089
}
},
"dataSources": {
"geometry": {
"id": "00005549-4e00-3c00-0000-0000596b63cf"
}
}
}
]
}
There is an end point in the Atlas API which might be closer to what we need - Fuzzy search.
It allows to set a typeahead flag and you can filter on entity type, so, for a GET reauest https://atlas.microsoft.com/search/fuzzy/json?api-version=1.0&query=Paris&typeahead=true&limit=3&entityType=Municipality,MunicipalitySubdivision,CountryTertiarySubdivision,CountrySubdivision
with your subscription key in the header
and an example return would be
"summary": {
"query": "paris",
"queryType": "NON_NEAR",
"queryTime": 26,
"numResults": 3,
"offset": 0,
"totalResults": 141,
"fuzzyLevel": 1,
"queryIntent": []
},
"results": [
{
"type": "Geography",
"id": "FR/GEO/p0/13312",
"score": 2.5989630222,
"entityType": "Municipality",
"address": {
"municipality": "Paris",
"countrySecondarySubdivision": "Paris",
"countrySubdivision": "Île-de-France",
"countryCode": "FR",
"country": "France",
"countryCodeISO3": "FRA",
"freeformAddress": "Paris"
},
"position": {
"lat": 48.85689,
"lon": 2.35085
},
"viewport": {
"topLeftPoint": {
"lat": 48.90216,
"lon": 2.2241
},
"btmRightPoint": {
"lat": 48.81552,
"lon": 2.46991
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 48.90216,
"lon": 2.2241
},
"btmRightPoint": {
"lat": 48.81552,
"lon": 2.46991
}
},
"dataSources": {
"geometry": {
"id": "00005858-5800-1200-0000-000077369045"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/119280",
"score": 2.4116733074,
"entityType": "Municipality",
"address": {
"municipality": "Paris",
"countrySecondarySubdivision": "Lamar",
"countrySubdivision": "TX",
"countrySubdivisionName": "Texas",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "Paris, TX"
},
"position": {
"lat": 33.66143,
"lon": -95.55632
},
"viewport": {
"topLeftPoint": {
"lat": 33.86768,
"lon": -95.66163
},
"btmRightPoint": {
"lat": 33.38955,
"lon": -95.31052
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 33.86768,
"lon": -95.66163
},
"btmRightPoint": {
"lat": 33.38955,
"lon": -95.31052
}
},
"dataSources": {
"geometry": {
"id": "00005554-3100-3c00-0000-0000596a4495"
}
}
},
{
"type": "Geography",
"id": "US/GEO/p0/106765",
"score": 2.4046759605,
"entityType": "Municipality",
"address": {
"municipality": "Paris",
"countrySecondarySubdivision": "Henry",
"countrySubdivision": "TN",
"countrySubdivisionName": "Tennessee",
"countryCode": "US",
"country": "United States",
"countryCodeISO3": "USA",
"freeformAddress": "Paris, TN"
},
"position": {
"lat": 36.30275,
"lon": -88.32636
},
"viewport": {
"topLeftPoint": {
"lat": 36.42548,
"lon": -88.59662
},
"btmRightPoint": {
"lat": 36.18254,
"lon": -88.15962
}
},
"boundingBox": {
"topLeftPoint": {
"lat": 36.42548,
"lon": -88.59662
},
"btmRightPoint": {
"lat": 36.18254,
"lon": -88.15962
}
},
"dataSources": {
"geometry": {
"id": "0000544e-3100-3c00-0000-00005969642b"
}
}
}
]
}

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 do I loop the JSON Request with different customer object data in Postman?

How do I loop the JSON Request with different customer object data in POSTMAN?
I'm looking to load a web application with test data.
{
"customer": {
"external_id": "EXT1221",
"name": "Elon Musk",
"address": "1405 North Ave, Chicago",
"address_second_line": "Apt 2",
"phone": "522-525-5555",
"email": "elon#company.com",
"zipcode": "60612",
"lat": "40.7833404",
"lng" : "-73.9527781",
"merchant_id" : 11271,
"confirmation_code" : "5320",
"allow_login" : true,
"allow_sending_email" : true,
"allow_sending_sms" : true,
"language": "en"
}
}
Since you have not defined structure how you would like to keep data. It looks like you are assuming data will be like :
{
"customers": {
"external_id": "EXT1221",
"name": "Elon Musk",
"address": "1405 North Ave, Chicago",
"address_second_line": "Apt 2",
"phone": "522-525-5555",
"email": "elon#company.com",
"zipcode": "60612",
"lat": "40.7833404",
"lng": "-73.9527781",
"merchant_id": 11271,
"confirmation_code": "5320",
"allow_login": true,
"allow_sending_email": true,
"allow_sending_sms": true,
"language": "en"
},
"customer": {
"external_id": "EXT1222",
"name": "Elon Musk2",
"address": "1405 North Ave, Chicago",
"address_second_line": "Apt 2",
"phone": "522-525-5555",
"email": "elon2#company.com",
"zipcode": "60612",
"lat": "40.7833404",
"lng": "-73.9527781",
"merchant_id": 11271,
"confirmation_code": "5320",
"allow_login": true,
"allow_sending_email": true,
"allow_sending_sms": true,
"language": "en"
}
}
In this case you can iterate as below :
Assuming testData is storing this JSON data.
_.each(testData,function(value,key){
console.log(`${JSON.stringify(key)} ${JSON.stringify(value)}`);
})
There is another way to do if JSON looks like as below :
{
"customers": [
{
"external_id": "EXT1221",
"name": "Elon Musk",
"address": "1405 North Ave, Chicago",
"address_second_line": "Apt 2",
"phone": "522-525-5555",
"email": "elon#company.com",
"zipcode": "60612",
"lat": "40.7833404",
"lng": "-73.9527781",
"merchant_id": 11271,
"confirmation_code": "5320",
"allow_login": true,
"allow_sending_email": true,
"allow_sending_sms": true,
"language": "en"
},
{
"external_id": "EXT1222",
"name": "Elon Musk2",
"address": "1405 North Ave, Chicago",
"address_second_line": "Apt 2",
"phone": "522-525-5555",
"email": "elon2#company.com",
"zipcode": "60612",
"lat": "40.7833404",
"lng": "-73.9527781",
"merchant_id": 11271,
"confirmation_code": "5320",
"allow_login": true,
"allow_sending_email": true,
"allow_sending_sms": true,
"language": "en"
}
]
}
Then you can iterate for each customer as below:
assuming testData storing above JSON.
_.each(testData.customers,function(customer){
console.log(customer);
});

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