I writing convenience wrapper on top of the Coinbase API.
One of the requirements is to get all user accounts.
Using proper set of scopes and after a successful OAuth authentication I can use /accountsendpoint.
But the answer is confusing:
{
"data": [
{
"id": "xxxx-xxxx-xxxx-xxxx",
"name": "BTC Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "BTC",
"name": "Bitcoin",
"color": "#F7931A",
"exponent": 8,
"type": "crypto",
"sort_index": 100,
"address_regex": "^([13][a-km-zA-HJ-NP-Z1-9]{25,34})|^(bc1([qpzry9x8gf2tvdw0s3jn54khce6mua7l]{39}|[qpzry9x8gf2tvdw0s3jn54khce6mua7l]{59}))$"
},
"balance": {
"amount": "0.03115207",
"currency": "BTC"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "ETC",
"name": "ETC Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "ETC",
"name": "Ethereum Classic",
"color": "#59D4AF",
"exponent": 8,
"type": "crypto",
"sort_index": 103,
"address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
},
"balance": {
"amount": "0.00000000",
"currency": "ETC"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "ZRX",
"name": "ZRX Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "ZRX",
"name": "0x",
"color": "#302C2C",
"exponent": 8,
"type": "crypto",
"sort_index": 105,
"address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
},
"balance": {
"amount": "0.00000000",
"currency": "ZRX"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "BAT",
"name": "BAT Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "BAT",
"name": "Basic Attention Token",
"color": "#FF5000",
"exponent": 8,
"type": "crypto",
"sort_index": 106,
"address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
},
"balance": {
"amount": "0.00000000",
"currency": "BAT"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "USDC",
"name": "USDC Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "USDC",
"name": "USD Coin",
"color": "#2775CA",
"exponent": 6,
"type": "crypto",
"sort_index": 107,
"address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
},
"balance": {
"amount": "0.000000",
"currency": "USDC"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "ZEC",
"name": "ZEC Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "ZEC",
"name": "Zcash",
"color": "#ECB244",
"exponent": 8,
"type": "crypto",
"sort_index": 108,
"address_regex": "^(t1|t3)[a-km-zA-HJ-NP-Z1-9]{33}$"
},
"balance": {
"amount": "0.00000000",
"currency": "ZEC"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "DAI",
"name": "DAI Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "DAI",
"name": "Dai",
"color": "#FFB74D",
"exponent": 8,
"type": "crypto",
"sort_index": 115,
"address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
},
"balance": {
"amount": "0.00000000",
"currency": "DAI"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "LINK",
"name": "LINK Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "LINK",
"name": "Chainlink",
"color": "#0667D0",
"exponent": 8,
"type": "crypto",
"sort_index": 122,
"address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
},
"balance": {
"amount": "0.00000000",
"currency": "LINK"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "XRP",
"name": "XRP Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "XRP",
"name": "XRP",
"color": "#222222",
"exponent": 6,
"type": "crypto",
"sort_index": 125,
"address_regex": "^r[1-9a-km-zA-HJ-NP-Z]{25,35}$"
},
"balance": {
"amount": "0.000000",
"currency": "XRP"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "REP",
"name": "REP Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "REP",
"name": "Augur",
"color": "#553580",
"exponent": 8,
"type": "crypto",
"sort_index": 126,
"address_regex": "^(?:0x)?[0-9a-fA-F]{40}$"
},
"balance": {
"amount": "0.00000000",
"currency": "REP"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
},
{
"id": "XLM",
"name": "XLM Wallet",
"primary": true,
"type": "wallet",
"currency": {
"code": "XLM",
"name": "Stellar Lumens",
"color": "#000000",
"exponent": 7,
"type": "crypto",
"sort_index": 127,
"address_regex": "^G[A-Z2-7]{55}$"
},
"balance": {
"amount": "0.0000000",
"currency": "XLM"
},
"createdAt": null,
"updatedAt": null,
"resource": "account",
"resourcePath": null
}
]
The endpoint returns incomplete list of the user accounts. I have at least two more coinbase accounts with non zero balance.
Additionally, the id are inconsistent - for BTC we have some sort of UUID in place, while other wallets are using currency code.
This makes /transactions endpoint requests returning 404 for the requests trying to point to the different than BTC wallets:
https://api.coinbase.com/v2/accounts/EOS/transactions.
Any idea how to get full list of accounts, plus how to work with the ID for other than BTC wallets?
The scopes I am using:
("wallet:accounts:read",
"wallet:accounts:update",
"wallet:transactions:read",
"wallet:transactions:request",
"wallet:transactions:send");
I added a transaction to one of the wallets, and it was removed from next /accounts request, making it even more confusing.
Referencing the Coinbase Documentation https://developers.coinbase.com/docs/wallet/coinbase-connect/permissions
You can add the scope account = allto the permission scope. This will enable read access for all coins
https://www.coinbase.com/oauth/authorize?response_type=code&client_id=YOUR_CLIENT_ID&account=all&redirect_uri=YOUR_CALLBACK_URL&scope=wallet:accounts:read,wallet:transactions:read
After a day of scratching my head finally found my answer.
Attaching the accounts happens on a single wallet basis.
User needs to add BTC, XRP, ETC etc. accounts/wallets separately.
Each receives it's own TokenResponse with access and refresh token, which your application needs to manage.
Still do not understand what is the purpose of returning in /accounts endpoint remaining accounts with non usable id.
Related
companyList = data['fields'][0]['choices'];
if (companyList.length != 0) {
int val;
for (val = 0; val < companyList.length; val++) {
final controller = TextEditingController();
final field = xTextfield(
txtlabel: "Values",
iconfield: bookmarksIcon,
);
setState(() {
_controllers.add(controller);
_fields.add(field);
});
}
}
But this works only if json response is same when it changes and Array object is differnet i got error here is my json that will be different everytime e.g
"inputtype": "dropdown", will make a dropdown widget and all data will be put into it and so on
{ "fields": [ { "id": 31, "name": "make", "isrequired": "required", "valuetype": "text", "priority": 1, "inputtype": "dropdown", "max_min": [], "rangeable": "false", "choices": [ { "id": 46, "name": "Samsung", "categoryextrafield_id": 31, "created_at": "2021-12-29T01:30:47.000000Z", "updated_at": "2021-12-29T01:30:47.000000Z", "priority": 10 }, { "id": 47, "name": "Dell", "categoryextrafield_id": 31, "created_at": "2021-12-29T01:30:52.000000Z", "updated_at": "2021-12-29T01:30:52.000000Z", "priority": 20 }, { "id": 48, "name": "IBM", "categoryextrafield_id": 31, "created_at": "2021-12-29T01:31:09.000000Z", "updated_at": "2021-12-29T01:31:09.000000Z", "priority": 30 }, { "id": 49, "name": "Acer", "categoryextrafield_id": 31, "created_at": "2021-12-29T01:31:24.000000Z", "updated_at": "2021-12-29T01:31:24.000000Z", "priority": 40 } ], "available": [] }, { "id": 32, "name": "model", "isrequired": "required", "valuetype": "text", "priority": 2, "inputtype": "textfield", "max_min": [], "rangeable": "false", "choices": [], "available": [ { "model": "a51" }, { "model": "y9s" }, { "model": "a31" }, { "model": "yS10" }, { "model": "Y10S" }, { "model": "A551" }, { "model": "node8" }, { "model": "s9" }, { "model": null }, { "model": "2021" }, { "model": "2020" }, { "model": "2010" }, { "model": "Civic" }, { "model": "2019" }, { "model": "Daewooy9" }, { "model": "corei5" }, { "model": "corei9" }, { "model": "corei3" }, { "model": "corei11" } ] }, { "id": 29, "name": "features", "isrequired": "required", "valuetype": "text", "priority": 3, "inputtype": "checkbox", "max_min": [], "rangeable": "false", "choices": [ { "id": 41, "name": "Bluetooth", "categoryextrafield_id": 29, "created_at": "2021-12-29T01:19:00.000000Z", "updated_at": "2021-12-29T01:19:00.000000Z", "priority": 1 }, { "id": 42, "name": "Fingerprint", "categoryextrafield_id": 29, "created_at": "2021-12-29T01:19:10.000000Z", "updated_at": "2021-12-29T01:19:10.000000Z", "priority": 10 }, { "id": 43, "name": "LedDisplay", "categoryextrafield_id": 29, "created_at": "2021-12-29T01:19:35.000000Z", "updated_at": "2021-12-29T01:19:35.000000Z", "priority": 15 } ], "available": [] }, { "id": 30, "name": "condition", "isrequired": "required", "valuetype": "text", "priority": 4, "inputtype": "radiobutton", "max_min": [], "rangeable": "false", "choices": [ { "id": 44, "name": "Used", "categoryextrafield_id": 30, "created_at": "2021-12-29T01:20:31.000000Z", "updated_at": "2021-12-29T01:20:31.000000Z", "priority": 10 }, { "id": 45, "name": "New", "categoryextrafield_id": 30, "created_at": "2021-12-29T01:20:38.000000Z", "updated_at": "2021-12-29T01:20:38.000000Z", "priority": 20 } ], "available": [] } ] }
You can use the Dynamic Widget package.
Just pass the widget as JSON data from the server and use a FutureBuilder to build it when your data arrives.
You will also need to change your JSON data accordingly.
The following is my json response from one of my APIs. I am trying to print image URL on console. You will see response is list of requests with each request having an array of images (json objects)
[
{
"image": [
{
"_id": "5fbfdc75aea26e00484a787a",
"name": "WhatsApp Image 2020-10-23 at 11.55.25 AM.jpeg",
"alternativeText": "",
"caption": "",
"hash": "Whats_App_Image_2020_10_23_at_11_55_25_AM_773f08e059",
"ext": ".jpeg",
"mime": "image/jpeg",
"size": 50.67,
"width": 590,
"height": 576,
"url": "/uploads/Whats_App_Image_2020_10_23_at_11_55_25_AM_773f08e059.jpeg",
"formats": {
"thumbnail": {
"name": "thumbnail_WhatsApp Image 2020-10-23 at 11.55.25 AM.jpeg",
"hash": "thumbnail_Whats_App_Image_2020_10_23_at_11_55_25_AM_773f08e059",
"ext": ".jpeg",
"mime": "image/jpeg",
"width": 160,
"height": 156,
"size": 5.97,
"path": null,
"url": "/uploads/thumbnail_Whats_App_Image_2020_10_23_at_11_55_25_AM_773f08e059.jpeg"
},
"small": {
"name": "small_WhatsApp Image 2020-10-23 at 11.55.25 AM.jpeg",
"hash": "small_Whats_App_Image_2020_10_23_at_11_55_25_AM_773f08e059",
"ext": ".jpeg",
"mime": "image/jpeg",
"width": 500,
"height": 488,
"size": 41.95,
"path": null,
"url": "/uploads/small_Whats_App_Image_2020_10_23_at_11_55_25_AM_773f08e059.jpeg"
}
},
"provider": "local",
"related": [
"5fbfdc7eaea26e00484a787b"
],
"createdAt": "2020-11-26T16:48:53.715Z",
"updatedAt": "2020-11-26T16:49:02.626Z",
"__v": 0,
"id": "5fbfdc75aea26e00484a787a"
}
],
"_id": "5fbfdc7eaea26e00484a787b",
"title": "I want an center table",
"description": "I want a 3x3 center table with Indian marble top",
"createdAt": "2020-11-26T16:49:02.619Z",
"updatedAt": "2020-11-26T17:23:40.655Z",
"__v": 0,
"category": {
"_id": "5fbfe21d0bbf020065dd0b1e",
"category_name": "Furniture",
"createdAt": "2020-11-26T17:13:01.743Z",
"updatedAt": "2020-11-26T17:13:01.754Z",
"__v": 0,
"id": "5fbfe21d0bbf020065dd0b1e"
},
"id": "5fbfdc7eaea26e00484a787b"
},
{
"image": [
{
"_id": "5fc073aaf41381008738f53a",
"name": "1RK-Apartment-for-Sale-in-Nalasopara-East-Mumbai-at-Sai-Krupa-Chawl-Listing-Photo_Kitchen.jpeg",
"alternativeText": "",
"caption": "",
"hash": "1_RK_Apartment_for_Sale_in_Nalasopara_East_Mumbai_at_Sai_Krupa_Chawl_Listing_Photo_Kitchen_90475427e3",
"ext": ".jpeg",
"mime": "image/jpeg",
"size": 12.22,
"width": 300,
"height": 300,
"url": "/uploads/1_RK_Apartment_for_Sale_in_Nalasopara_East_Mumbai_at_Sai_Krupa_Chawl_Listing_Photo_Kitchen_90475427e3.jpeg",
"formats": {
"thumbnail": {
"name": "thumbnail_1RK-Apartment-for-Sale-in-Nalasopara-East-Mumbai-at-Sai-Krupa-Chawl-Listing-Photo_Kitchen.jpeg",
"hash": "thumbnail_1_RK_Apartment_for_Sale_in_Nalasopara_East_Mumbai_at_Sai_Krupa_Chawl_Listing_Photo_Kitchen_90475427e3",
"ext": ".jpeg",
"mime": "image/jpeg",
"width": 156,
"height": 156,
"size": 6.45,
"path": null,
"url": "/uploads/thumbnail_1_RK_Apartment_for_Sale_in_Nalasopara_East_Mumbai_at_Sai_Krupa_Chawl_Listing_Photo_Kitchen_90475427e3.jpeg"
}
},
"provider": "local",
"related": [
"5fc07407f41381008738f53c"
],
"createdAt": "2020-11-27T03:34:02.177Z",
"updatedAt": "2020-11-27T03:35:35.325Z",
"__v": 0,
"id": "5fc073aaf41381008738f53a"
},
{
"_id": "5fc073fdf41381008738f53b",
"name": "images.jpeg",
"alternativeText": "",
"caption": "",
"hash": "images_4ba1796688",
"ext": ".jpeg",
"mime": "image/jpeg",
"size": 9.55,
"width": 351,
"height": 144,
"url": "/uploads/images_4ba1796688.jpeg",
"formats": {
"thumbnail": {
"name": "thumbnail_images.jpeg",
"hash": "thumbnail_images_4ba1796688",
"ext": ".jpeg",
"mime": "image/jpeg",
"width": 245,
"height": 101,
"size": 6.44,
"path": null,
"url": "/uploads/thumbnail_images_4ba1796688.jpeg"
}
},
"provider": "local",
"related": [
"5fc07407f41381008738f53c"
],
"createdAt": "2020-11-27T03:35:25.211Z",
"updatedAt": "2020-11-27T03:35:35.325Z",
"__v": 0,
"id": "5fc073fdf41381008738f53b"
}
],
"_id": "5fc07407f41381008738f53c",
"title": "pest control के लिए",
"description": "हमारा घर 700 वर्गफुट का है",
"createdAt": "2020-11-27T03:35:35.313Z",
"updatedAt": "2020-11-27T03:36:20.592Z",
"__v": 0,
"category": {
"_id": "5fc07424f41381008738f53f",
"category_name": "Pest Control",
"createdAt": "2020-11-27T03:36:04.739Z",
"updatedAt": "2020-11-27T03:36:04.748Z",
"__v": 0,
"id": "5fc07424f41381008738f53f"
},
"id": "5fc07407f41381008738f53c"
}
]
I now want to show Image URL and referring it in following manner in React Native.
Following is React Native code for view
<View>
{isLoading ? <ActivityIndicator/> : (
<FlatList
data={data}
keyExtractor={({ id }, index) => id}
renderItem={ renderItem }
/>
)}
</View>
and renderItem is defined as following
function renderItem({ item }) {
console.log(item.image[0].name);
}
and I get following error
undefined is not an object (evaluating 'item.image[0]')
Can you point where am I going wrong?
You're not reading data properly. As you're using nested JSON object so you can access data using the following approaches:
For Single Image:
item[0].image[0].url
For all the Images:
item.forEach(function(value, key) {
value.image.map(image => console.log(image.url));
});
I have tried your code in react native expo snack it's working fine Expo Snack Link
I am new to getting JSON into SQL Server 2016, I thought I had it down, but I notice that I am missing some details from the array, looking at the image, there are four address', but I saw there are some more address' missing for example Burrows Rd, and Urana RD. How can I make sure that all the address' captured?
https://i.stack.imgur.com/erzBV.jpg
#json nvarchar(max)
#json = N'{
"response": [
{
"application": {
"info": {
"dat_id": "010.2018.00036494.001",
"development_type": "Residential - Single new dwelling",
"application_type": "DA",
"last_modified_date": "2018-12-03T11:35:24+11:00",
"description": "Residence, Garage & Colorbond Shed, Demolition of Existing Residence & Tree Removal",
"authority": {
"ref": "http://gemini:82/ApplicationTracker/atdis/1.0",
"name": "AlburyCity"
},
"lodgement_date": "2018-10-26T00:00:00+11:00",
"determination_date": null,
"determination_type": "Pending",
"status": "In Progress",
"notification_start_date": null,
"notification_end_date": null,
"officer": "David Flood",
"estimated_cost": "Not applicable.",
"related_apps": [ ]
},
"reference": {
"more_info_url": "http://gemini:82/ApplicationTracker/Application/ApplicationDetails/010.2018.00036494.001/",
"comments_url": null
},
"locations": [
{
"land_title_ref": {
"torrens": {
"lot": "11",
"section": null,
"dpsp_id": "DP 1031272"
}
},
"address": {
"street": "680 Centaur RD",
"suburb": "HAMILTON VALLEY",
"state": "NSW",
"postcode": "2641"
},
"geometry": null
},
{
"land_title_ref": {
"torrens": {
"lot": "11",
"section": null,
"dpsp_id": "DP 1031272"
}
},
"address": {
"street": "Urana RD",
"suburb": "HAMILTON VALLEY",
"state": "NSW",
"postcode": "2641"
},
"geometry": null
},
{
"land_title_ref": {
"torrens": {
"lot": "11",
"section": null,
"dpsp_id": "DP 1031272"
}
},
"address": {
"street": "Burrows RD",
"suburb": "HAMILTON VALLEY",
"state": "NSW",
"postcode": "2641"
},
"geometry": null
}
],
"events": [
{
"id": "3680347",
"timestamp": "2018-11-01T15:58:00+11:00",
"description": "Public Notification",
"event_type": "PNOT",
"status": "COMP"
},
{
"id": "3680348",
"timestamp": "2018-11-01T15:58:00+11:00",
"description": "Referral Engineering",
"event_type": "ENG",
"status": "COMP"
},
{
"id": "3680349",
"timestamp": "2018-11-01T15:59:00+11:00",
"description": "Referal Parks & Recreation",
"event_type": "TREE",
"status": "COMP"
},
{
"id": "3680350",
"timestamp": "2018-11-01T16:00:00+11:00",
"description": "Acknowledgement to Applicant",
"event_type": "ACKN",
"status": "COMP"
},
{
"id": "3683617",
"timestamp": "2018-11-21T14:59:00+11:00",
"description": "Site Assessment Inspection",
"event_type": "SITE",
"status": "PASS"
},
{
"id": "3685155",
"timestamp": "2018-12-03T11:37:00+11:00",
"description": "Assessment Report",
"event_type": "ASS3",
"status": "COMP"
}
],
"documents": [
{
"ref": "DOC18/163129",
"title": "Statement of Environmental Effects - SEE",
"document_url": "http://gemini:82/ApplicationTracker/atdis/1.0/Document/Download?key=6hF7YEiv0qE=&fileName=Statement+of+Environmental+Effects+-+SEE.PDF"
},
{
"ref": "DOC18/163139",
"title": "Site Plan and Elevations",
"document_url": "http://gemini:82/ApplicationTracker/atdis/1.0/Document/Download?key=1Gv3GVOIHCM=&fileName=Site+Plan+and+Elevations.PDF"
}
],
"people": [
{
"name": "Karyn Ford",
"role": "Applicant",
"contact": "6023 8287"
}
],
"extended": {
"software_vendor": "Civica",
"software_vendor_url": "http://www.civica.com.au"
}
}
},
{
"application": {
"info": {
"dat_id": "017.2018.00036017.001",
"development_type": "Subdivision Only",
"application_type": "SCC",
"last_modified_date": "2018-12-03T10:19:25+11:00",
"description": "Roads, Sewer, Water & Drainage for Two (2) Lot Torrens Title Subdivisi on",
"authority": {
"ref": "http://gemini:82/ApplicationTracker/atdis/1.0",
"name": "AlburyCity"
},
"lodgement_date": "2018-11-14T00:00:00+11:00",
"determination_date": "2018-11-29T00:00:00+11:00",
"determination_type": "Approved under delegation",
"status": "Determined",
"notification_start_date": null,
"notification_end_date": null,
"officer": "Sharna Holland",
"estimated_cost": "Not applicable.",
"related_apps": [ "http://gemini:82/ApplicationTracker/atdis/1.0/010.2018.00036017.001.json" ]
},
"reference": {
"more_info_url": "http://gemini:82/ApplicationTracker/Application/ApplicationDetails/017.2018.00036017.001/",
"comments_url": null
},
"locations": [
{
"land_title_ref": {
"torrens": {
"lot": "A",
"section": null,
"dpsp_id": "DP 161410"
}
},
"address": {
"street": "419 Hovell ST",
"suburb": "SOUTH ALBURY",
"state": "NSW",
"postcode": "2640"
},
"geometry": null
},
{
"land_title_ref": {
"torrens": {
"lot": "A",
"section": null,
"dpsp_id": "DP 161410"
}
},
"address": {
"street": "Charles ST",
"suburb": "SOUTH ALBURY",
"state": "NSW",
"postcode": "2640"
},
"geometry": null
}
],
"events": [
{
"id": "3683888",
"timestamp": "2018-11-23T14:03:00+11:00",
"description": "Acknowledgement to Applicant",
"event_type": "ACKN",
"status": "COMP"
},
{
"id": "3683902",
"timestamp": "2018-11-23T15:21:00+11:00",
"description": "Referral Engineering",
"event_type": "ENG",
"status": "COMP"
},
{
"id": "3683903",
"timestamp": "2018-11-23T15:21:00+11:00",
"description": "Referral Building Surveyor 3",
"event_type": "BS3",
"status": "COMP"
},
{
"id": "3683904",
"timestamp": "2018-11-23T15:21:00+11:00",
"description": "Referral Trainee Town Planner",
"event_type": "TTP1",
"status": "COMP"
},
{
"id": "3684791",
"timestamp": "2018-11-29T14:36:00+11:00",
"description": "Collected Determination",
"event_type": "COLL",
"status": "COMP"
}
],
"documents": [
{
"ref": "DOC18/177392",
"title": "Subdivision Works Certificate",
"document_url": "http://gemini:82/ApplicationTracker/atdis/1.0/Document/Download?key=8qU1Pkawfvg=&fileName=Subdivision+Works+Certificate.PDF"
}
],
"people": [
{
"name": "Eslers Land Consulting",
"role": "Applicant",
"contact": "6021 1322"
}
],
"extended": {
"software_vendor": "Civica",
"software_vendor_url": "http://www.civica.com.au"
}
}
},
{
"application": {
"info": {
"dat_id": "010.2016.00034838.001",
"development_type": "Residential - New multi unit",
"application_type": "DA",
"last_modified_date": "2018-12-03T09:36:09+11:00",
"description": "Twenty (20) Detached Self Contained Residences - Kensington Gardens Retirement Village",
"authority": {
"ref": "http://gemini:82/ApplicationTracker/atdis/1.0",
"name": "AlburyCity"
},
"lodgement_date": "2016-08-17T00:00:00+10:00",
"determination_date": "2016-10-24T00:00:00+11:00",
"determination_type": "Approved under delegation",
"status": "Determined",
"notification_start_date": null,
"notification_end_date": null,
"officer": "Christopher Eldred",
"estimated_cost": "Not applicable.",
"related_apps": [ "http://gemini:82/ApplicationTracker/atdis/1.0/011.2016.00034838.001.json", "http://gemini:82/ApplicationTracker/atdis/1.0/011.2016.00034838.002.json", "http://gemini:82/ApplicationTracker/atdis/1.0/011.2016.00034838.003.json", "http://gemini:82/ApplicationTracker/atdis/1.0/011.2016.00034838.004.json", "http://gemini:82/ApplicationTracker/atdis/1.0/011.2016.00034838.005.json", "http://gemini:82/ApplicationTracker/atdis/1.0/011.2016.00034838.006.json", "http://gemini:82/ApplicationTracker/atdis/1.0/011.2016.00034838.007.json", "http://gemini:82/ApplicationTracker/atdis/1.0/011.2016.00034838.008.json", "http://gemini:82/ApplicationTracker/atdis/1.0/011.2016.00034838.009.json", "http://gemini:82/ApplicationTracker/atdis/1.0/011.2016.00034838.010.json", "http://gemini:82/ApplicationTracker/atdis/1.0/011.2016.00034838.011.json", "http://gemini:82/ApplicationTracker/atdis/1.0/011.2016.00034838.012.json" ]
},
"reference": {
"more_info_url": "http://gemini:82/ApplicationTracker/Application/ApplicationDetails/010.2016.00034838.001/",
"comments_url": null
},
"locations": [
{
"land_title_ref": {
"torrens": {
"lot": "2",
"section": null,
"dpsp_id": "DP 874732"
}
},
"address": {
"street": "100 Table Top RD",
"suburb": "THURGOONA",
"state": "NSW",
"postcode": "2640"
},
"geometry": null
}
],
"events": [
{
"id": "3583145",
"timestamp": "2016-08-17T14:13:00+10:00",
"description": "Further Information Requested",
"event_type": "INFO",
"status": "COMP"
},
{
"id": "3573096",
"timestamp": "2016-08-18T15:34:00+10:00",
"description": "Public Notification",
"event_type": "PNOT",
"status": "COMP"
},
{
"id": "3573097",
"timestamp": "2016-08-18T15:37:00+10:00",
"description": "Referral Building Surveyor 2",
"event_type": "BS2",
"status": "COMP"
},
{
"id": "3573098",
"timestamp": "2016-08-18T15:37:00+10:00",
"description": "Referral Plumbing Inspector",
"event_type": "PI",
"status": "COMP"
},
{
"id": "3573099",
"timestamp": "2016-08-18T15:37:00+10:00",
"description": "Referral Engineering",
"event_type": "ENG",
"status": "COMP"
},
{
"id": "3573100",
"timestamp": "2016-08-18T15:38:00+10:00",
"description": "Referral Environmental Planner",
"event_type": "ENV",
"status": "COMP"
},
{
"id": "3573103",
"timestamp": "2016-08-18T15:43:43+10:00",
"description": "Acknowledgement to Applicant",
"event_type": "ACKN",
"status": "COMP"
},
{
"id": "3575194",
"timestamp": "2016-09-06T00:00:00+10:00",
"description": "Assessment Report",
"event_type": "ASS3",
"status": "COMP"
}
],
"documents": [
{
"ref": "DOC16/209893",
"title": "Statement of Environmental Effects - SEE",
"document_url": "http://gemini:82/ApplicationTracker/atdis/1.0/Document/Download?key=sQkVV9rEsTU=&fileName=Statement+of+Environmental+Effects+-+SEE.PDF"
},
{
"ref": "DOC16/209896",
"title": "Site Plan & Elevations",
"document_url": "http://gemini:82/ApplicationTracker/atdis/1.0/Document/Download?key=3dRqEZHzGeo=&fileName=Site+Plan+%26+Elevations.PDF"
},
{
"ref": "DOC16/211819",
"title": "Assessment Report",
"document_url": "http://gemini:82/ApplicationTracker/atdis/1.0/Document/Download?key=DVTQkQQqbns=&fileName=Assessment+Report.PDF"
},
{
"ref": "DOC16/240764",
"title": "Development Consent",
"document_url": "http://gemini:82/ApplicationTracker/atdis/1.0/Document/Download?key=TY+Y3zjyDKw=&fileName=Development+Consent.PDF"
}
],
"people": [
{
"name": "Kensington Gardens Lifestyle Estates",
"role": "Applicant",
"contact": "6049 3100"
}
],
"extended": {
"software_vendor": "Civica",
"software_vendor_url": "http://www.civica.com.au"
}
}
},
{
"application": {
"info": {
"dat_id": "010.2018.00036468.001",
"development_type": "Residential - Single new dwelling",
"application_type": "DA",
"last_modified_date": "2018-11-30T17:17:25+11:00",
"description": "Residence, Garage and Retaining Walls",
"authority": {
"ref": "http://gemini:82/ApplicationTracker/atdis/1.0",
"name": "AlburyCity"
},
"lodgement_date": "2018-10-19T00:00:00+11:00",
"determination_date": "2018-11-26T00:00:00+11:00",
"determination_type": "Approved under delegation",
"status": "Determined",
"notification_start_date": null,
"notification_end_date": null,
"officer": "David Flood",
"estimated_cost": "Not applicable.",
"related_apps": [ "http://gemini:82/ApplicationTracker/atdis/1.0/011.2018.00036468.001.json" ]
},
"reference": {
"more_info_url": "http://gemini:82/ApplicationTracker/Application/ApplicationDetails/010.2018.00036468.001/",
"comments_url": null
},
"locations": [
{
"land_title_ref": {
"torrens": {
"lot": "218",
"section": null,
"dpsp_id": "DP 1228226"
}
},
"address": {
"street": "20 Stockman CRCT",
"suburb": "THURGOONA",
"state": "NSW",
"postcode": "2640"
},
"geometry": null
}
],
"events": [
{
"id": "3678966",
"timestamp": "2018-10-25T10:47:00+11:00",
"description": "Public Notification",
"event_type": "PNOT",
"status": "COMP"
},
{
"id": "3678967",
"timestamp": "2018-10-25T10:48:00+11:00",
"description": "Referral Engineering",
"event_type": "ENG",
"status": "COMP"
},
{
"id": "3678974",
"timestamp": "2018-10-25T10:51:00+11:00",
"description": "Acknowledgement to Applicant",
"event_type": "ACKN",
"status": "COMP"
},
{
"id": "3681955",
"timestamp": "2018-11-01T15:49:00+11:00",
"description": "Site Assessment Inspection",
"event_type": "SITE",
"status": "COMP"
},
{
"id": "3684251",
"timestamp": "2018-11-27T10:24:00+11:00",
"description": "Collected Determination",
"event_type": "COLL",
"status": "COMP"
}
],
"documents": [
{
"ref": "DOC18/159026",
"title": "Statement of Environmental Effects - SEE",
"document_url": "http://gemini:82/ApplicationTracker/atdis/1.0/Document/Download?key=MaiWkTs8V+g=&fileName=Statement+of+Environmental+Effects+-+SEE.PDF"
},
{
"ref": "DOC18/159033",
"title": "Site Plan and Elevations and Superseded Plan",
"document_url": "http://gemini:82/ApplicationTracker/atdis/1.0/Document/Download?key=2xpqra8gNb0=&fileName=Site+Plan+and+Elevations+and+Superseded+Plan.PDF"
},
{
"ref": "DOC18/162569",
"title": "Assessment Report - Bldg Residential",
"document_url": "http://gemini:82/ApplicationTracker/atdis/1.0/Document/Download?key=bKYCMP01aJE=&fileName=Assessment+Report+-+Bldg+Residential.PDF"
},
{
"ref": "DOC18/168584",
"title": "Development Consent",
"document_url": "http://gemini:82/ApplicationTracker/atdis/1.0/Document/Download?key=SxGG/yKi68s=&fileName=Development+Consent.PDF"
}
],
"people": [
{
"name": "Alatalo Bros",
"role": "Applicant",
"contact": "02 6055 0180"
}
],
"extended": {
"software_vendor": "Civica",
"software_vendor_url": "http://www.civica.com.au"
}
}
}
],
"count": 4,
"pagination": {
"previous": null,
"next": 2,
"current": 1,
"per_page": 4,
"count": 24091,
"pages": 6023
}
}'
select *
from OPENJSON(#json, '$.response')
with
([lot] varchar(200) '$.application.locations[0].land_title_ref.torrens.lot',
[section] varchar(200) '$.application.locations[0].land_title_ref.torrens.section',
[dpsp_id] varchar(200) '$.application.locations[0].land_title_ref.torrens.dpsp_id',
[Street] varchar(200) '$.application.locations[0].address.street',
[suburb] varchar(200) '$.application.locations[0].address.suburb',
[state] varchar(200) '$.application.locations[0].address.state',
[postcode] varchar(200) '$.application.locations[0].address.postcode',
[geometry] varchar(200) '$.application.locations[0].geometry'
)
Try this:
select L.*
from OPENJSON(#json,'$.response') R
CROSS APPLY OPENJSON(R.[value], '$.application.locations')
with
(
[lot] varchar(200) '$.land_title_ref.torrens.lot',
[section] varchar(200) '$.land_title_ref.torrens.section',
[dpsp_id] varchar(200) '$.land_title_ref.torrens.dpsp_id',
[Street] varchar(200) '$.address.street',
[suburb] varchar(200) '$.address.suburb',
[state] varchar(200) '$.address.state',
[postcode] varchar(200) '$.address.postcode',
[geometry] varchar(200) '$.geometry'
) L
The locations is an array, so we need to use cross apply and OPENSJON to get all elements.
I am using angularjs for frontend and loopback for backend and elastic search for the database.
I have a model with properties as:
"name": {
"type": "string",
"required": true
},
"mobileNumber": {
"type": "string",
"required": true
},
"email": {
"type": "string"
},
"message": {
"type": "string",
"required": true
},
"quantity": {
"type": "number",
"required": true
},
"price": {
"type": "number",
"required": true
},
"status": {
"type": "string",
"required": true,
"default": "open"
}
},
data as:
{
"_index": "XXXXXX",
"_type": "XXXXX",
"_id": "XXXXXXX",
"_version": 1,
"_score": 1,
"_source": {
"name": "aadil kirana",
"email": "aadil#gmail.com",
"message": "dfgfb dgfggf",
"quantity": 3434,
"price": 5454,
"status": "open",
"createdAt": "2017-12-19T14:53:41.727Z",
"updatedAt": "2017-12-19T14:53:41.727Z"
}
}
Status could be open, processing, close, reject and failure.
All I want is to get the data in the order where I can see all the open status data ordered by createdAt date,
then all the prcoessing status data ordered by createdAt dat
and so on....
I tried using loopback filters as:
filter = {
order: ['status ASC','createdAt DESC'],
};
but this gives me First all the close status data ordered by date, then all the open status data ordered by date and so on, that status ordered alphabetically.
Please help me to get the desired result.
You can add a new property to your data as statusOrder and define
1 -> open
2 -> close
...
and order by statusOrder instead of status when you are ordering status.
All I want is to get the data in the order where I can see all the
open status data ordered by createdAt date, then all the prcoessing
status data ordered by createdAt dat and so on....
A workaround for this could be to let Elasticsearch do the sort with custom order e.g. in this context the status could be ordered as open followed by processing followed by close followed by reject followed by failure. It can be done with Function Score Query. Some more insights could also be found here
Sample input data for bulk insert:
POST custom/sort/_bulk?pretty
{"index" : {"_index" : "custom"}}
{"status": "open", "createdAt": "2017-12-19T14:53:41.727Z"}
{"index" : {"_index" : "custom"}}
{"status": "open", "createdAt": "2017-12-18T14:53:41.727Z"}
{"index" : {"_index" : "custom"}}
{"status": "processing", "createdAt": "2017-12-19T14:53:41.727Z"}
{"index" : {"_index" : "custom"}}
{"status": "processing", "createdAt": "2017-12-17T14:53:41.727Z"}
{"index" : {"_index" : "custom"}}
{"status": "close", "createdAt": "2017-12-19T14:53:41.727Z"}
{"index" : {"_index" : "custom"}}
{"status": "close", "createdAt": "2017-12-19T15:53:41.727Z"}
{"index" : {"_index" : "custom"}}
{"status": "failure", "createdAt": "2017-12-19T10:53:41.727Z"}
{"index" : {"_index" : "custom"}}
{"status": "failure", "createdAt": "2017-12-19T14:59:41.727Z"}
{"index" : {"_index" : "custom"}}
{"status": "reject", "createdAt": "2017-12-19T14:53:40.727Z"}
{"index" : {"_index" : "custom"}}
{"status": "reject", "createdAt": "2017-12-19T14:53:41.727Z"}
Sample response from elastic search (without custom order):
Query:
GET custom/sort/_search?filter_path=took,hits.total,hits.hits._score,hits.hits._source
{
"took": 0,
"hits": {
"total": 10,
"hits": [
{
"_score": 1,
"_source": {
"status": "processing",
"createdAt": "2017-12-19T14:53:41.727Z"
}
},
{
"_score": 1,
"_source": {
"status": "close",
"createdAt": "2017-12-19T14:53:41.727Z"
}
},
{
"_score": 1,
"_source": {
"status": "reject",
"createdAt": "2017-12-19T14:53:40.727Z"
}
},
{
"_score": 1,
"_source": {
"status": "open",
"createdAt": "2017-12-18T14:53:41.727Z"
}
},
{
"_score": 1,
"_source": {
"status": "failure",
"createdAt": "2017-12-19T10:53:41.727Z"
}
},
{
"_score": 1,
"_source": {
"status": "failure",
"createdAt": "2017-12-19T14:59:41.727Z"
}
},
{
"_score": 1,
"_source": {
"status": "reject",
"createdAt": "2017-12-19T14:53:41.727Z"
}
},
{
"_score": 1,
"_source": {
"status": "open",
"createdAt": "2017-12-19T14:53:41.727Z"
}
},
{
"_score": 1,
"_source": {
"status": "processing",
"createdAt": "2017-12-17T14:53:41.727Z"
}
},
{
"_score": 1,
"_source": {
"status": "close",
"createdAt": "2017-12-19T15:53:41.727Z"
}
}
]
}
}
Query to mimic custom ordering :
GET custom/sort/_search?filter_path=took,hits.hits._id,hits.hits._score,hits.hits._source,hits.hits.sort
{
"query": {
"function_score": {
"boost_mode": "replace",
"query": {
"constant_score": {
"filter": {
"terms": {
"status.keyword": [
"open",
"processing",
"close",
"reject",
"failure"
]
}
}
}
},
"functions": [
{
"filter": {
"term": {
"status.keyword": "open"
}
},
"weight": 4
},
{
"filter": {
"term": {
"status.keyword": "processing"
}
},
"weight": 3
},
{
"filter": {
"term": {
"status.keyword": "close"
}
},
"weight": 2
},
{
"filter": {
"term": {
"status.keyword": "reject"
}
},
"weight": 1
},
{
"filter": {
"term": {
"status.keyword": "failure"
}
},
"weight": 0
}
]
}
},
"sort": [
{
"_score": {
"order": "desc"
},
"createdAt": {
"order": "asc"
}
}
]
}
Output (with custom order):
{
"took": 4,
"hits": {
"hits": [
{
"_id": "grOucmABwtSchlgLKlaV",
"_score": 4,
"_source": {
"status": "open",
"createdAt": "2017-12-18T14:53:41.727Z"
},
"sort": [
4,
1513608821727
]
},
{
"_id": "gbOucmABwtSchlgLKlaV",
"_score": 4,
"_source": {
"status": "open",
"createdAt": "2017-12-19T14:53:41.727Z"
},
"sort": [
4,
1513695221727
]
},
{
"_id": "hLOucmABwtSchlgLKlaV",
"_score": 3,
"_source": {
"status": "processing",
"createdAt": "2017-12-17T14:53:41.727Z"
},
"sort": [
3,
1513522421727
]
},
{
"_id": "g7OucmABwtSchlgLKlaV",
"_score": 3,
"_source": {
"status": "processing",
"createdAt": "2017-12-19T14:53:41.727Z"
},
"sort": [
3,
1513695221727
]
},
{
"_id": "hbOucmABwtSchlgLKlaV",
"_score": 2,
"_source": {
"status": "close",
"createdAt": "2017-12-19T14:53:41.727Z"
},
"sort": [
2,
1513695221727
]
},
{
"_id": "hrOucmABwtSchlgLKlaV",
"_score": 2,
"_source": {
"status": "close",
"createdAt": "2017-12-19T15:53:41.727Z"
},
"sort": [
2,
1513698821727
]
},
{
"_id": "ibOucmABwtSchlgLKlaV",
"_score": 1,
"_source": {
"status": "reject",
"createdAt": "2017-12-19T14:53:40.727Z"
},
"sort": [
1,
1513695220727
]
},
{
"_id": "irOucmABwtSchlgLKlaV",
"_score": 1,
"_source": {
"status": "reject",
"createdAt": "2017-12-19T14:53:41.727Z"
},
"sort": [
1,
1513695221727
]
},
{
"_id": "h7OucmABwtSchlgLKlaV",
"_score": 0,
"_source": {
"status": "failure",
"createdAt": "2017-12-19T10:53:41.727Z"
},
"sort": [
0,
1513680821727
]
},
{
"_id": "iLOucmABwtSchlgLKlaV",
"_score": 0,
"_source": {
"status": "failure",
"createdAt": "2017-12-19T14:59:41.727Z"
},
"sort": [
0,
1513695581727
]
}
]
}
}
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.