This fiidle have a sample dropdown list which data is comes from hard coded json format as given below.
var data = [
{
"department": "IT",
"subject": [
{
"title": "Programmer",
"services": [
{
"name": "example1"},
{
"name": "example2"}
]
},
{
"title": "Solutions Architect",
"services": [
{
"name": "example3"},
{
"name": "example4"}
]
},
{
"title": "Database Developer"}
]},
{
"department": "Accounting",
"subject": [
{
"title": "Accountant"},
{
"title": "Payroll Officer"},
{
"title": "Accounts Clerk"},
{
"title": "Analyst"},
{
"title": "Financial Controller"}
]},
{
"department": "HR",
"subject": [
{
"title": "Recruitment Consultant"},
{
"title": "Change Management"},
{
"title": "Industrial Relations"}
]},
{
"department": "Marketing",
"subject": [
{
"title": "Market Researcher"},
{
"title": "Marketing Manager"},
{
"title": "Marketing Co-ordinator"}
]}
]
Is it possible to create the same type of dropdown with data in google spreadsheet? If so, what is the data format required in spreadsheet?
EDIT: Is it possible to create the same dropdown menu using data source something as
var query = new google.visualization.Query("http://spreadsheets.google.com/tq?key=0AozvCNI02VmpdDBKYUhRdVVhb2xGel91c2FkV1daYkE&single=true&gid=0&pub=1");
query.send(handleQueryResponse);
}
function handleQueryResponse(response) {
var data = response.getDataTable();
which is coming from this spreadsheet
Related
I am trying to build a bash scripts to manage my google contacts programatically using the google contacts api. From the api-reference I can see the rest api to list full/single contacts entry in xml or json format. But I cannot able see any filter option to fetch name, mobile number alone.
https://www.google.com/m8/feeds/contacts/{userEmail}/full?alt=json
Response:
{
"version": "1.0",
"encoding": "UTF-8",
"entry": {
"id": {
"$t": "http://www.google.com/m8/feeds/contacts/xxxxxxxx%40gmail.com/base/xxxxxxxxxxxxxxxx"
},
"updated": {
"$t": "2019-03-16T02:56:27.686Z"
},
"category": [
{
"scheme": "http://schemas.google.com/g/2005#kind",
"term": "http://schemas.google.com/contact/2008#contact"
}
],
"title": {
"$t": "NEW_CONTACT_NAME",
"type": "text"
},
"link": [
{
}
],
"content": {
"$t": "Tets Entry!",
"type": "text"
},
"gd$organization": [
{
"rel": "http://schemas.google.com/g/2005#other",
"gd$orgName": {
"$t": "javis"
}
}
],
"gd$email": [
{
"address": "xxxxxxxxxx#gmail.com",
"rel": "http://schemas.google.com/g/2005#other"
}
],
"gd$phoneNumber": [
{
"label": "Prime",
"uri": "tel:+xx-xxxxx-xxxxx",
"$t": "+xx xxxxx xxxxx"
}
],
"gContact$groupMembershipInfo": [
{
"deleted": "false",
"href": "http://www.google.com/m8/feeds/groups/xxxxxxxx%40gmail.com/base/xxxxxxxxxxxxxxxx"
}
],
"xmlns": "http://www.w3.org/2005/Atom",
"xmlns$batch": "http://schemas.google.com/gdata/batch",
"xmlns$gContact": "http://schemas.google.com/contact/2008",
"xmlns$gd": "http://schemas.google.com/g/2005"
}
}
Could you please help me to find the solution to filter specific field like contact id, name, number or mail from the json response.
I'm new to Groovy. But, I can try with some simple code lines to extract the data.
I have read the from Parse JSON using groovy script (using JsonSlurper). But it didn't help in my case.
My code line:
{
"errors": false,
"address_data": [
{
"address_id": "567",
"township": {
"id": "41079",
"name": "Test Data"
},
"city": {
"id": "1622",
"name": "Test City"
},
"region": {
"id": "663",
"name": "Metro Test"
},
"stock_source_code": "Test",
"is_default_address": false
},
{
"address_id": "45444",
"township": {
"id": "41079",
"name": "Test Test"
},
"city": {
"id": "1622",
"name": "Test City"
},
"region": {
"id": "663",
"name": "Metro Test Taguig"
},
"is_default_address": true
},
{
"address_id": "45444",
"township": {
"id": "888888",
"name": "Apas"
},
"city": {
"id": "432",
"name": "Test City"
},
"region": {
"id": "591",
"name": "Test Cebu"
},
"stock_source_code": "testce",
"is_default_address": false
}
]
}
My code lines:
def response = "data_above";
def object = new JsonSlurper().parseText(response);
def errors = object.errors
if (errors == false) { //could access object.errors property
log.info "Checking condition"
def addressData = object.address_data // Cannot get the data
}
How can I get the address_data property?
According to the documentation (https://forge.autodesk.com/en/docs/data/v2/tutorials/download-file/)
I should get the storage object id from included.relationships.storage.data.id.
I can do it for all files uploaded to the bim360 except plans pdf files.
There is nothing about 'storage' in a whole response.
Here is "included" from my response:
'''
"included": [
{
"type": "versions",
"id": "XXX",
"attributes": {
"name": "1ST FLOOR PLAN",
"displayName": "1ST FLOOR PLAN",
"createTime": "2019-01-10T09:19:16Z",
"createUserId": "3MYGKJ73V3SD",
"createUserName": "XXX",
"lastModifiedTime": "2019-01-10T09:19:19Z",
"lastModifiedUserId": "XXX",
"lastModifiedUserName": "XXX",
"versionNumber": 1,
"extension": {
"type": "versions:autodesk.bim360:Document",
"version": "1.0",
"schema": {
"href": "https://developer.api.autodesk.com/schema/v1/versions/versions:autodesk.bim360:Document-1.0"
},
"data": {
"processState": "PROCESSING_COMPLETE",
"viewableId": "1",
"viewableGuid": "XXX",
"viewableName": "(1)",
"viewableOrder": 1,
"sourceFileName": "A1-1 DIMS FIRST FLOOR DIMENSION PLAN_V1_2019-01-10_09-54-54am.pdf"
}
}
},
"links": {
"self": {
"href": "XXX"
}
},
"relationships": {
"item": {
"data": {
"type": "items",
"id": "XXX"
},
"links": {
"related": {
"href": "XXX"
}
}
},
"refs": {
"links": {
"self": {
"href": "XXX"
},
"related": {
"href": "XXX"
}
}
},
"links": {
"links": {
"self": {
"href": "XXX"
}
}
},
"downloadFormats": {
"links": {
"related": {
"href": "XXX"
}
}
}
}
}
]
'''
How can I deal with it?
Yes, please call GET versions/:version_id/relationships/refs instead. Since the item listed in the Plan folder is a type of items:autodesk.bim360:Document, this type item won't have storage attribute shown in its responses of GET versions/:version_id and GET items/:item_id directly. see also here: Download a Document with Autodesk API
I'm working with cloudantDB as DB for my spring application.
The thing that I'm trying to do is:
check if there is a timeslot and topic in the document
if there is a topic filled in:
check the userId who has submitted that topic and return all of the items for that user.
{
"_id": "393c7748cf487f7c5223839dfdf5adf9",
"_rev": "2-889c6d9d14fcc3c90a00e91aca5f2f4c",
"name": "conference 1",
"type": "conference",
"location": "conf loc",
"tag": "confTag",
"startDate": "2015-05-04T22:00:00.000+0000",
"endDate": "2015-05-08T22:00:00.000+0000",
"timeslots": {
"8a03b160-48e3-4f99-be38-2a2da34e5890": {
"id": "8a03b160-48e3-4f99-be38-2a2da34e5890",
"startDate": "2015-04-07T10:45:00.000+0000",
"endDate": "2015-05-07T12:45:00.000+0000",
"location": "Location",
"topic": {
"id": "4ad235ef-5938-4461-8a2e-346bf105c5b6",
"title": "wa nen coole title",
"description": "dees is een goei omschrijving",
"tags": "cloud, tag",
"attachment": "file.exe",
"speakerId": null
}
},
"a59b1dfd-d1c5-491f-bc02-807e38595ba4": {
"id": "a59b1dfd-d1c5-491f-bc02-807e38595ba4",
"startDate": "2015-05-05T10:00:00.000+0000",
"endDate": "2015-05-05T11:15:00.000+0000",
"location": "mlkjs",
"topic": {
"id": "8b753adb-9a15-486f-9209-b9cc5ef134a1",
"title": "test132",
"description": "met speakerId",
"tags": "sldkjf",
"attachment": "kklsjdf",
"speakerId": "speaker"
}
},
"080153e7-f8bc-453e-b49a-a1df4679ceef": {
"id": "080153e7-f8bc-453e-b49a-a1df4679ceef",
"startDate": "2015-05-09T11:30:00.000+0000",
"endDate": "2015-05-09T13:30:00.000+0000",
"location": "file upload",
"topic": {
"id": "e3533a60-a0ba-4439-a9e9-b29e69be47db",
"title": "fdgdfg",
"description": "fdsgdsggdfgdfg",
"tags": "dfgsdg",
"attachment": null,
"speakerId": null
}
}
},
"defaultTwitterText": "Hallo",
"twitterUrl": "https://twitter.com/intent/tweet?button_hashtag=confTag&text=Hallo"
}
So far I have this:
function(doc) {
{ if (doc.type === 'conference') {
if(doc.timeslots.size !==0 ){
emit( null, doc);
}
}
}
}
Thanks!
I think you might want something like:
function (doc) {
if (doc.type == 'conference'){
if (doc.timeslots){
for (var i in doc.timeslots) {
if(doc.timeslots[i].topic){
emit(doc.timeslots[i].topic.speakerId, doc.timeslots[i])
}
};
}
}
}
that'll make a view of key:speaker, value: topic object, which you can then query with ?key=speaker to see the list of all the topic objects for the speaker.
I am using JSON to dynamically populate a parent/child dropdown lists. I have it working to fill the parent drop down and have the child drop down filling with the same parent data. How do I loop through the sub array of the selected value from the parent?
My "each" line (key is the value from my parent DDL:
var key = $(this).prev("input").val();
$.each(jsondata.Id[key].HourTypeCodes, function(i, item) {
My JSON
[{
"Id": 1,
"Title": "Vacation",
"HourTypeCodes": [
{
"Id": "05",
"Title": "VAC POLICE/FIRE"
},
{
"Id": "04",
"Title": "VACATION"
},
{
"Id": "62",
"Title": "VACATION HOURS PURCHASED"
},
{
"Id": "60",
"Title": "VACATION SELL BACK"
}
]
},
{
"Id": 2,
"Title": "Holiday",
"HourTypeCodes": [
{
"Id": "08",
"Title": "HOLIDAY"
}
]
},
{
"Id": 3,
"Title": "Floating Holiday",
"HourTypeCodes": [
{
"Id": "09",
"Title": "FLOATING HOLIDAY"
}
]
}]
I figured it out finally! I found this: http://inderpreetsingh.com/2010/10/14/javascriptjson-find-index-in-an-array-of-objects/
From there these are the two lines that work:
var i = findIndexByKeyValue(jsonRequestType, "Id", key);
$.each(jsonRequestType[i].HourTypeCodes, function(i, item) {