I want to get some elements from json response from youtube api:
I get this response in my script:
{
"version": "1.0",
"encoding": "UTF-8",
"feed": {
"xmlns": "http://www.w3.org/2005/Atom",
"xmlns$media": "http://search.yahoo.com/mrss/",
"xmlns$openSearch": "http://a9.com/-/spec/opensearchrss/1.0/",
"xmlns$gd": "http://schemas.google.com/g/2005",
"xmlns$yt": "http://gdata.youtube.com/schemas/2007",
"id": {
"$t": "http://gdata.youtube.com/feeds/api/videos"
},
"updated": {
"$t": "2013-01-13T15:48:18.863Z"
},
"category": [
{
"scheme": "http://schemas.google.com/g/2005#kind",
"term": "http://gdata.youtube.com/schemas/2007#video"
}
],
"title": {
"$t": "Videos matching: humor",
"type": "text"
},
"logo": {
"$t": "http://www.youtube.com/img/pic_youtubelogo_123x63.gif"
},
"link": [
{
"rel": "alternate",
"type": "text/html",
"href": "http://www.youtube.com"
},
{
"rel": "http://schemas.google.com/g/2005#feed",
"type": "application/atom+xml",
"href": "http://gdata.youtube.com/feeds/api/videos"
},
{
"rel": "http://schemas.google.com/g/2005#batch",
"type": "application/atom+xml",
"href": "http://gdata.youtube.com/feeds/api/videos/batch"
},
{
"rel": "self",
"type": "application/atom+xml",
"href": "http://gdata.youtube.com/feeds/api/videos?alt=json&q=humor&start-index=1&max-results=1&lr=es&orderby=published"
},
{
"rel": "next",
"type": "application/atom+xml",
"href": "http://gdata.youtube.com/feeds/api/videos?alt=json&q=humor&start-index=2&max-results=1&lr=es&orderby=published"
}
],
"author": [
{
"name": {
"$t": "YouTube"
},
"uri": {
"$t": "http://www.youtube.com/"
}
}
],
"generator": {
"$t": "YouTube data API",
"version": "2.1",
"uri": "http://gdata.youtube.com"
},
"openSearch$totalResults": {
"$t": 10595
},
"openSearch$startIndex": {
"$t": 1
},
"openSearch$itemsPerPage": {
"$t": 1
},
"entry": [
{
"id": {
"$t": "http://gdata.youtube.com/feeds/api/videos/HAUdFeouzgM"
},
"published": {
"$t": "2013-01-13T15:43:26.000Z"
},
"updated": {
"$t": "2013-01-13T15:43:26.000Z"
},
"category": [
{
"scheme": "http://schemas.google.com/g/2005#kind",
"term": "http://gdata.youtube.com/schemas/2007#video"
},
{
"scheme": "http://gdata.youtube.com/schemas/2007/categories.cat",
"term": "Film",
"label": "Cine y animación"
}
],
"title": {
"$t": "Chica Troll en dibujo: TiparracoSA (IrukoArt)",
"type": "text"
},
"content": {
"$t": "Canal del artista creador: www.youtube.com Si quieres ver camaras ocultas dale aqui: www.youtube.com Si quieres ver a la chica troll VS pervertidos aqui: www.youtube.com Canal principal --- (Bromas con camara oculta y humor) www.youtube.com Sigueme en Twitter: twitter.com Sigueme en Facebook: www.facebook.com",
"type": "text"
},
"link": [
{
"rel": "alternate",
"type": "text/html",
"href": "http://www.youtube.com/watch?v=HAUdFeouzgM&feature=youtube_gdata"
},
{
"rel": "http://gdata.youtube.com/schemas/2007#video.responses",
"type": "application/atom+xml",
"href": "http://gdata.youtube.com/feeds/api/videos/HAUdFeouzgM/responses"
},
{
"rel": "http://gdata.youtube.com/schemas/2007#video.related",
"type": "application/atom+xml",
"href": "http://gdata.youtube.com/feeds/api/videos/HAUdFeouzgM/related"
},
{
"rel": "http://gdata.youtube.com/schemas/2007#mobile",
"type": "text/html",
"href": "http://m.youtube.com/details?v=HAUdFeouzgM"
},
{
"rel": "self",
"type": "application/atom+xml",
"href": "http://gdata.youtube.com/feeds/api/videos/HAUdFeouzgM"
}
],
"author": [
{
"name": {
"$t": "TiparracoTV"
},
"uri": {
"$t": "http://gdata.youtube.com/feeds/api/users/TiparracoTV"
}
}
],
"gd$comments": {
"gd$feedLink": {
"rel": "http://gdata.youtube.com/schemas/2007#comments",
"href": "http://gdata.youtube.com/feeds/api/videos/HAUdFeouzgM/comments",
"countHint": 0
}
},
"media$group": {
"media$category": [
{
"$t": "Film",
"label": "Cine y animación",
"scheme": "http://gdata.youtube.com/schemas/2007/categories.cat"
}
],
"media$content": [
{
"url": "http://www.youtube.com/v/HAUdFeouzgM?version=3&f=videos&app=youtube_gdata",
"type": "application/x-shockwave-flash",
"medium": "video",
"isDefault": "true",
"expression": "full",
"duration": 324,
"yt$format": 5
},
{
"url": "rtsp://v1.cache2.c.youtube.com/CiILENy73wIaGQkDzi7qFR0FHBMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp",
"type": "video/3gpp",
"medium": "video",
"expression": "full",
"duration": 324,
"yt$format": 1
},
{
"url": "rtsp://v1.cache2.c.youtube.com/CiILENy73wIaGQkDzi7qFR0FHBMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp",
"type": "video/3gpp",
"medium": "video",
"expression": "full",
"duration": 324,
"yt$format": 6
}
],
"media$description": {
"$t": "Canal del artista creador: www.youtube.com Si quieres ver camaras ocultas dale aqui: www.youtube.com Si quieres ver a la chica troll VS pervertidos aqui: www.youtube.com Canal principal --- (Bromas con camara oculta y humor) www.youtube.com Sigueme en Twitter: twitter.com Sigueme en Facebook: www.facebook.com",
"type": "plain"
},
"media$keywords": {
},
"media$player": [
{
"url": "http://www.youtube.com/watch?v=HAUdFeouzgM&feature=youtube_gdata_player"
}
],
"media$thumbnail": [
{
"url": "http://i.ytimg.com/vi/HAUdFeouzgM/0.jpg",
"height": 360,
"width": 480,
"time": "00:02:42"
},
{
"url": "http://i.ytimg.com/vi/HAUdFeouzgM/1.jpg",
"height": 90,
"width": 120,
"time": "00:01:21"
},
{
"url": "http://i.ytimg.com/vi/HAUdFeouzgM/2.jpg",
"height": 90,
"width": 120,
"time": "00:02:42"
},
{
"url": "http://i.ytimg.com/vi/HAUdFeouzgM/3.jpg",
"height": 90,
"width": 120,
"time": "00:04:03"
}
],
"media$title": {
"$t": "Chica Troll en dibujo: TiparracoSA (IrukoArt)",
"type": "plain"
},
"yt$duration": {
"seconds": "324"
}
},
"yt$statistics": {
"favoriteCount": "0",
"viewCount": "1"
}
}
]
}
}
I want to access some elements like title, tags, and link to use in my script. I eval json and i try to access to elements, but are inside arrays and another json objects i think and can't get the script work:
var datos=data.responseText;
var respuesta = eval("(" + data.responseText + ")");
alert(respuesta.entry.title);
This code don't work, how i can access to the elements?
Try alert(respuesta.entry[0].title); instead. entry is an array.
EDIT Also as we noted in the comments entry is yet one more level deeper in the json. The correct expression is actually: alert(respuesta.feed.entry[0].title);. I suggest you use Online JSON Beautifier to beutify your json and make it easier to understand.
Related
I'm trying to add the collection field (name and family) to my metadata using VSC. Not sure where to begin or how to do it. Any help appreciated. Thanks!
{
"name": "Solflare X NFT",
"symbol": "",
"description": "Celebratory Solflare NFT for the Solflare X launch",
"seller_fee_basis_points": 0,
"image": "https://www.arweave.net/abcd5678?ext=png",
"animation_url": "https://www.arweave.net/efgh1234?ext=mp4",
"external_url": "https://solflare.com",
"attributes": [
{ "trait_type": "web", "value": "yes" },
{ "trait_type": "mobile", "value": "yes" },
{ "trait_type": "extension", "value": "yes" }
],
"collection": { "name": "Solflare X NFT", "family": "Solflare" },
"properties": {
"files": [
{
"uri": "https://www.arweave.net/abcd5678?ext=png",
"type": "image/png"
},
{
"uri": "https://watch.videodelivery.net/9876jkl",
"type": "unknown",
"cdn": true
},
{ "uri": "https://www.arweave.net/efgh1234?ext=mp4", "type": "video/mp4" }
],
"category": "video",
"creators": [
{ "address": "SOLFLR15asd9d21325bsadythp547912501b", "share": 100 }
]
}
}
I am trying to convert a JSON to CSV with JavaScript. The problem is I keep getting the error: Cannot convert undefined or null to object
at Function.keys.
I only want the 'features.attributes' keys and values from the data. I have no problem getting the keys but the values seems to be a problem. Any help wuld be appreciated.
json
{
"displayFieldName": "label",
"fieldAliases": {
"OBJECTID": "OBJECTID",
"label": "label",
"west": "west",
"east": "east",
"north": "north",
"south": "south",
"scale": "scale",
"title": "title",
"edition": "edition",
"available": "available",
"physHold": "physHold",
"primeMer": "primeMer",
"projection": "projection",
"publisher": "publisher",
"datePub": "datePub",
"color": "color",
"recId": "recId",
"note": "note",
"location": "location",
"bathLines": "bathLines",
"bathInterv": "bathInterv",
"instCallNo": "instCallNo",
"setTitle": "setTitle",
"sheetId": "sheetId",
"digita": "digita",
"titleAlt": "titleAlt",
"digHold": "digHold",
"miradorURL": "miradorURL",
"iiifURL": "iiifURL",
"Shape_Length": "Shape_Length",
"Shape_Area": "Shape_Area"
},
"geometryType": "esriGeometryPolygon",
"spatialReference": {
"wkid": 102100,
"latestWkid": 3857
},
"fields": [
{
"name": "OBJECTID",
"type": "esriFieldTypeOID",
"alias": "OBJECTID"
},
{
"name": "label",
"type": "esriFieldTypeString",
"alias": "label",
"length": 50
},
{
"name": "west",
"type": "esriFieldTypeDouble",
"alias": "west"
},
{
"name": "east",
"type": "esriFieldTypeDouble",
"alias": "east"
},
{
"name": "north",
"type": "esriFieldTypeDouble",
"alias": "north"
},
{
"name": "south",
"type": "esriFieldTypeDouble",
"alias": "south"
},
{
"name": "scale",
"type": "esriFieldTypeInteger",
"alias": "scale"
},
{
"name": "title",
"type": "esriFieldTypeString",
"alias": "title",
"length": 55
},
{
"name": "edition",
"type": "esriFieldTypeString",
"alias": "edition",
"length": 85
},
{
"name": "available",
"type": "esriFieldTypeSmallInteger",
"alias": "available"
},
{
"name": "physHold",
"type": "esriFieldTypeString",
"alias": "physHold",
"length": 3
},
{
"name": "primeMer",
"type": "esriFieldTypeSmallInteger",
"alias": "primeMer"
},
{
"name": "projection",
"type": "esriFieldTypeString",
"alias": "projection",
"length": 19
},
{
"name": "publisher",
"type": "esriFieldTypeString",
"alias": "publisher",
"length": 33
},
{
"name": "datePub",
"type": "esriFieldTypeSmallInteger",
"alias": "datePub"
},
{
"name": "color",
"type": "esriFieldTypeSmallInteger",
"alias": "color"
},
{
"name": "recId",
"type": "esriFieldTypeString",
"alias": "recId",
"length": 30
},
{
"name": "note",
"type": "esriFieldTypeString",
"alias": "note",
"length": 254
},
{
"name": "location",
"type": "esriFieldTypeString",
"alias": "location",
"length": 254
},
{
"name": "bathLines",
"type": "esriFieldTypeString",
"alias": "bathLines",
"length": 5
},
{
"name": "bathInterv",
"type": "esriFieldTypeString",
"alias": "bathInterv",
"length": 50
},
{
"name": "instCallNo",
"type": "esriFieldTypeString",
"alias": "instCallNo",
"length": 50
},
{
"name": "setTitle",
"type": "esriFieldTypeString",
"alias": "setTitle",
"length": 50
},
{
"name": "sheetId",
"type": "esriFieldTypeInteger",
"alias": "sheetId"
},
{
"name": "digita",
"type": "esriFieldTypeString",
"alias": "digita",
"length": 8000
},
{
"name": "titleAlt",
"type": "esriFieldTypeString",
"alias": "titleAlt",
"length": 8000
},
{
"name": "digHold",
"type": "esriFieldTypeString",
"alias": "digHold",
"length": 8000
},
{
"name": "miradorURL",
"type": "esriFieldTypeString",
"alias": "miradorURL",
"length": 8000
},
{
"name": "iiifURL",
"type": "esriFieldTypeString",
"alias": "iiifURL",
"length": 8000
},
{
"name": "Shape_Length",
"type": "esriFieldTypeDouble",
"alias": "Shape_Length"
},
{
"name": "Shape_Area",
"type": "esriFieldTypeDouble",
"alias": "Shape_Area"
}
],
"features": [
{
"attributes": {
"OBJECTID": 1,
"label": " ",
"west": -5.8263888899999996,
"east": -5.7838888900000001,
"north": 35.770000000000003,
"south": 35.814166669999999,
"scale": 5000,
"title": "Port de Tanger",
"edition": " ",
"available": 1,
"physHold": "yes",
"primeMer": 131,
"projection": " ",
"publisher": " ",
"datePub": 1908,
"color": 31,
"recId": "agsmap026454",
"note": "\\\\ $a Relief shown by form lines and hachures. Depths shown by bathymetric isolines and soundings. | \\\\ $a \"Nota, le de\u0301tail de la ville, emprunte\u0301 au plan local espangnol, a e\u0301te\u0301 rectifie\u0301 par la triangulation et le nivellement effectue\u0301s par la",
"location": " ",
"bathLines": " ",
"bathInterv": " ",
"instCallNo": " ",
"setTitle": "French Charts",
"sheetId": 21511,
"digita": "agsmap026454",
"titleAlt": "Tangier, port, 1908",
"Shape_Length": 21584.807399988174,
"Shape_Area": 28676605.202176783
},
"geometry": {
"rings": [
[
[
-648590.64440000057,
4269019.7031000033
],
[
-648590.64440000057,
4275081.0283999965
],
[
-643859.56599999964,
4275081.0283999965
],
[
-643859.56599999964,
4269019.7031000033
],
[
-648590.64440000057,
4269019.7031000033
]
]
]
}
}
]
}
js
function exportJSONToCSV(objArray) {
var arr = typeof objArray !== 'object' ? JSON.parse(objArray) : objArray;
var str =
`${Object.keys(arr[0])
.map((value) => `"${value}"`)
.join(',')}` + '\r\n';
var csvContent = arr.reduce((st, next) => {
console.log(next);
st +=
`${Object.values(next)
.map((value) => `"${value}"`)
.join(',')}` + '\r\n';
return st;
}, str);
var element = document.createElement('a');
element.href = 'data:text/csv;charset=utf-8,' + encodeURI(csvContent);
element.target = '_blank';
element.download = 'export.csv';
element.click();
}
What about:
var json = ... // YOUR JSON
var features = json.features;
var isFirstIterationCompleted = false;
var csv = '';
features.forEach(e => {
var attributesKeys = Object.keys(e.attributes);
if (!isFirstIterationCompleted) {
csv += attributesKeys.join(';') + '\n'; // separated by semicolon
isFirstIterationCompleted = true;
}
attributesKeys.forEach(a => {
csv += e.attributes[a] + ';';
});
csv += '\n';
})
console.log(csv);
I'm working with the Google's API to get the info of my contact list and after use console log
function fetch(token) {
$.ajax({
url: "https://www.google.com/m8/feeds/contacts/default/full?access_token=" + token.access_token + "&alt=json",
dataType: "JSON",
success:function(data) {
var json = JSON.stringify(data);
console.log(json);
}
});
}
I'm getting this info
{
"version": "1.0",
"encoding": "UTF-8",
"feed": {
"xmlns": "http://www.w3.org/2005/Atom",
"xmlns$openSearch": "http://a9.com/-/spec/opensearchrss/1.0/",
"xmlns$batch": "http://schemas.google.com/gdata/batch",
"xmlns$gd": "http://schemas.google.com/g/2005",
"xmlns$gContact": "http://schemas.google.com/contact/2008",
"id": {
"$t": "sifo.contacto#gmail.com"
},
"updated": {
"$t": "2016-02-22T19:33:36.064Z"
},
"category": [{
"scheme": "http://schemas.google.com/g/2005#kind",
"term": "http://schemas.google.com/contact/2008#contact"
}],
"title": {
"type": "text",
"$t": "Sifo Sistema Inteligente de Facturación Online's Contacts"
},
"link": [{
"rel": "alternate",
"type": "text/html",
"href": "http://www.google.com/"
}, {
"rel": "http://schemas.google.com/g/2005#feed",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/full"
}, {
"rel": "http://schemas.google.com/g/2005#post",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/full"
}, {
"rel": "http://schemas.google.com/g/2005#batch",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/full/batch"
}, {
"rel": "self",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/full?alt=json&max-results=25"
}, {
"rel": "next",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/full?alt=json&start-index=26&max-results=25"
}],
"author": [{
"name": {
"$t": "Sifo Sistema Inteligente de Facturación Online"
},
"email": {
"$t": "sifo.contacto#gmail.com"
}
}],
"generator": {
"version": "1.0",
"uri": "http://www.google.com/m8/feeds",
"$t": "Contacts"
},
"openSearch$totalResults": {
"$t": "704"
},
"openSearch$startIndex": {
"$t": "1"
},
"openSearch$itemsPerPage": {
"$t": "25"
},
"entry": [{
"id": {
"$t": "http://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/base/1600788a7596f9"
},
"updated": {
"$t": "2015-10-08T19:48:21.315Z"
},
"category": [{
"scheme": "http://schemas.google.com/g/2005#kind",
"term": "http://schemas.google.com/contact/2008#contact"
}],
"title": {
"type": "text",
"$t": "Lic. Jose Lugo"
},
"link": [{
"rel": "http://schemas.google.com/contacts/2008/rel#edit-photo",
"type": "image/*",
"href": "https://www.google.com/m8/feeds/photos/media/sifo.contacto%40gmail.com/1600788a7596f9/1B2M2Y8AsgTpgAmY7PhCfg"
}, {
"rel": "self",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/full/1600788a7596f9"
}, {
"rel": "edit",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/full/1600788a7596f9/1444333701315001"
}],
"gd$email": [{
"rel": "http://schemas.google.com/g/2005#other",
"address": "jose.lugo#mecrg.com",
"primary": "true"
}]
}, {
"id": {
"$t": "http://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/base/243862896da102"
},
"updated": {
"$t": "2016-02-11T22:58:30.580Z"
},
"category": [{
"scheme": "http://schemas.google.com/g/2005#kind",
"term": "http://schemas.google.com/contact/2008#contact"
}],
"title": {
"type": "text",
"$t": ""
},
"link": [{
"rel": "http://schemas.google.com/contacts/2008/rel#edit-photo",
"type": "image/*",
"href": "https://www.google.com/m8/feeds/photos/media/sifo.contacto%40gmail.com/243862896da102/qPx9RZ6Tppge180vMVnHUw"
}, {
"rel": "http://schemas.google.com/contacts/2008/rel#photo",
"type": "image/*",
"href": "https://www.google.com/m8/feeds/photos/media/sifo.contacto%40gmail.com/243862896da102"
}, {
"rel": "self",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/full/243862896da102"
}, {
"rel": "edit",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/full/243862896da102/1455231510580001"
}],
"gd$email": [{
"rel": "http://schemas.google.com/g/2005#other",
"address": "sharai.alvarez#gmail.com",
"primary": "true"
}]
}, {
"id": {
"$t": "http://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/base/406bac09eee821"
},
"updated": {
"$t": "2016-02-11T16:26:46.318Z"
},
"category": [{
"scheme": "http://schemas.google.com/g/2005#kind",
"term": "http://schemas.google.com/contact/2008#contact"
}],
"title": {
"type": "text",
"$t": ""
},
"link": [{
"rel": "http://schemas.google.com/contacts/2008/rel#edit-photo",
"type": "image/*",
"href": "https://www.google.com/m8/feeds/photos/media/sifo.contacto%40gmail.com/406bac09eee821/1B2M2Y8AsgTpgAmY7PhCfg"
}, {
"rel": "self",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/full/406bac09eee821"
}, {
"rel": "edit",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/full/406bac09eee821/1455208006318001"
}],
"gd$email": [{
"rel": "http://schemas.google.com/g/2005#other",
"address": "rosyalonso3#hotmail.com",
"primary": "true"
}]
}, {
"id": {
"$t": "http://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/base/48a21c08062798"
},
"updated": {
"$t": "2016-02-18T21:08:19.835Z"
},
"category": [{
"scheme": "http://schemas.google.com/g/2005#kind",
"term": "http://schemas.google.com/contact/2008#contact"
}],
"title": {
"type": "text",
"$t": ""
},
"link": [{
"rel": "http://schemas.google.com/contacts/2008/rel#edit-photo",
"type": "image/*",
"href": "https://www.google.com/m8/feeds/photos/media/sifo.contacto%40gmail.com/48a21c08062798/1B2M2Y8AsgTpgAmY7PhCfg"
}, {
"rel": "self",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/full/48a21c08062798"
}, {
"rel": "edit",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/full/48a21c08062798/1455829699835001"
}],
"gd$email": [{
"rel": "http://schemas.google.com/g/2005#other",
"address": "joseluisgr15#yahoo.com",
"primary": "true"
}]
}, {
"id": {
"$t": "http://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/base/596ac60cfe288f"
},
"updated": {
"$t": "2015-06-10T21:01:08.157Z"
},
"category": [{
"scheme": "http://schemas.google.com/g/2005#kind",
"term": "http://schemas.google.com/contact/2008#contact"
}],
"title": {
"type": "text",
"$t": "FLORA EXOTICA DE CHIAPAS"
},
"link": [{
"rel": "http://schemas.google.com/contacts/2008/rel#edit-photo",
"type": "image/*",
"href": "https://www.google.com/m8/feeds/photos/media/sifo.contacto%40gmail.com/596ac60cfe288f/1B2M2Y8AsgTpgAmY7PhCfg"
}, {
"rel": "self",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/full/596ac60cfe288f"
}, {
"rel": "edit",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/full/596ac60cfe288f/1433970068157001"
}],
"gd$email": [{
"rel": "http://schemas.google.com/g/2005#other",
"address": "tropiflores#hotmail.com",
"primary": "true"
}]
}, {
"id": {
"$t": "http://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/base/69c8d608c00f66"
},
"updated": {
"$t": "2016-01-07T17:00:01.946Z"
},
"category": [{
"scheme": "http://schemas.google.com/g/2005#kind",
"term": "http://schemas.google.com/contact/2008#contact"
}],
"title": {
"type": "text",
"$t": ""
},
"link": [{
"rel": "http://schemas.google.com/contacts/2008/rel#edit-photo",
"type": "image/*",
"href": "https://www.google.com/m8/feeds/photos/media/sifo.contacto%40gmail.com/69c8d608c00f66/bc1NAkUY9UZ5B9Ih8I16dw"
}, {
"rel": "http://schemas.google.com/contacts/2008/rel#photo",
"type": "image/*",
"href": "https://www.google.com/m8/feeds/photos/media/sifo.contacto%40gmail.com/69c8d608c00f66"
}, {
"rel": "self",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/full/69c8d608c00f66"
}, {
"rel": "edit",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/full/69c8d608c00f66/1452186001946000"
}],
"gd$email": [{
"rel": "http://schemas.google.com/g/2005#other",
"address": "Omarpuribe#gmail.com",
"primary": "true"
}]
}, {
"id": {
"$t": "http://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/base/8640870e6f72d7"
},
"updated": {
"$t": "2016-01-20T15:54:41.842Z"
},
"category": [{
"scheme": "http://schemas.google.com/g/2005#kind",
"term": "http://schemas.google.com/contact/2008#contact"
}],
"title": {
"type": "text",
"$t": ""
},
"link": [{
"rel": "http://schemas.google.com/contacts/2008/rel#edit-photo",
"type": "image/*",
"href": "https://www.google.com/m8/feeds/photos/media/sifo.contacto%40gmail.com/8640870e6f72d7/1B2M2Y8AsgTpgAmY7PhCfg"
}, {
"rel": "self",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/full/8640870e6f72d7"
}, {
"rel": "edit",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/full/8640870e6f72d7/1453305281842002"
}],
"gd$email": [{
"rel": "http://schemas.google.com/g/2005#other",
"address": "aguixcor#gmail.com",
"primary": "true"
}]
}, {
"id": {
"$t": "http://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/base/adb5708dff4555"
},
"updated": {
"$t": "2016-01-07T20:46:02.243Z"
},
"category": [{
"scheme": "http://schemas.google.com/g/2005#kind",
"term": "http://schemas.google.com/contact/2008#contact"
}],
"title": {
"type": "text",
"$t": ""
},
"link": [{
"rel": "http://schemas.google.com/contacts/2008/rel#edit-photo",
"type": "image/*",
"href": "https://www.google.com/m8/feeds/photos/media/sifo.contacto%40gmail.com/adb5708dff4555/1B2M2Y8AsgTpgAmY7PhCfg"
}, {
"rel": "self",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/full/adb5708dff4555"
}, {
"rel": "edit",
"type": "application/atom+xml",
"href": "https://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/full/adb5708dff4555/1452199562243000"
}],
"gd$email": [{
"rel": "http://schemas.google.com/g/2005#other",
"address": "Ponyjr12#hotmail.com",
"primary": "true"
}]
}, {
"id": {
"$t": "http://www.google.com/m8/feeds/contacts/sifo.contacto%40gmail.com/base/e5831f8fe0aeb2"
},
"updated": {
"$t": "2016-02-11T18:22:13.253Z"
},
"category": [{
"scheme": "http://schemas.google.com/g/2005#kind",
"term": "http://schemas.google.com/contact/2008#contact"
}],
"title": {
"type": "text",
"$t": ""
},
"link": [{
"rel": "http://schemas.google.com/contacts/2008/rel#edit-photo",
"type": "image/*",
"href": "https://www.google.com/m8/feeds/photos/media/sifo.c
and I would like to read the value of "address" to get the email address but I have no idea how, I tried with $.each but the value was "undefined" everytime, what should do I to reach the email?
what exactly were you trying to call $.each on? On the entire data object, or some property?
If you just want to get the list of email addresses, you can use a map function to iterate over the data.feed.entry array and pull out the nested gd$email[0].address value like this:
var emailAddresses = data.feed.entry.map(function(entry) {
//take the first gd$email item the entry has
var gdEmail = entry['gd$email'][0];
//this assumes all entries will have a gd$email,
// you may want to implement a null check
return gdEmail.address;
});
I am using Angular Schema Form to generate input fields for me. I am wondering if there is any way I could customize the input fields by adding IDs. I tried looking at the documentation (https://github.com/Textalk/angular-schema-form/blob/development/docs/index.md), but it doesn't seem like the current version supports it (only adding classes).
I've just done a bit of research and on the "Kitchen Sink" Example on -
http://schemaform.io/examples/bootstrap-example.html
they have used this code
Form:
`[
{
"type": "fieldset",
"title": "Stuff",
"items": [
{
"type": "tabs",
"tabs": [
{
"title": "Simple stuff",
"items": [
{
"key": "name",
"placeholder": "Check the console",
"onChange": "log(modelValue)",
"feedback": "{'glyphicon': true, 'glyphicon-ok': hasSuccess(), 'glyphicon-star': !hasSuccess() }"
},
{
"key": "favorite",
"feedback": false
}
]
},
{
"title": "More stuff",
"items": [
"attributes.eyecolor",
"attributes.haircolor",
{
"key": "attributes.shoulders.left",
"title": "Left shoulder",
"description": "This value is copied to attributes.shoulders.right in the model",
"copyValueTo": [
"attributes.shoulders.right"
]
},
{
"key": "shoesizeLeft",
"feedback": false,
"copyValueTo": [
"shoesizeRight"
]
},
{
"key": "shoesizeRight"
},
{
"key": "invitation",
"tinymceOptions": {
"toolbar": [
"undo redo| styleselect | bold italic | link image",
"alignleft aligncenter alignright"
]
}
},
"things",
"dislike"
]
}
]
}
]
},
{
"type": "help",
"helpvalue": "<hr>"
},
"soul",
{
"type": "conditional",
"condition": "modelData.soul",
"items": [
{
"key": "soulserial",
"placeholder": "ex. 666"
}
]
},
{
"key": "date",
"minDate": "2014-06-20"
},
{
"key": "radio",
"type": "radios",
"titleMap": [
{
"value": "Transistor",
"name": "Transistor <br> Not the tube kind."
},
{
"value": "Tube",
"name": "Tube <br> The tube kind."
}
]
},
{
"key": "radio2",
"type": "radios-inline",
"titleMap": [
{
"value": "Transistor",
"name": "Transistor <br> Not the tube kind."
},
{
"value": "Tube",
"name": "Tube <br> The tube kind."
}
]
},
{
"key": "radiobuttons",
"style": {
"selected": "btn-success",
"unselected": "btn-default"
},
"type": "radiobuttons",
"notitle": true
},
{
"type": "actions",
"items": [
{
"type": "submit",
"style": "btn-info",
"title": "Do It!"
},
{
"type": "button",
"style": "btn-danger",
"title": "Noooooooooooo",
"onClick": "sayNo()"
}
]
}
]`
Schema:
`{
"type": "object",
"required": [
"name",
"shoesizeLeft"
],
"properties": {
"name": {
"title": "Name",
"description": "Gimme yea name lad",
"type": "string",
"pattern": "^[^/]*$",
"minLength": 2
},
"invitation": {
"type": "string",
"format": "html",
"title": "Invitation Design",
"description": "Design the invitation in full technicolor HTML"
},
"favorite": {
"title": "Favorite",
"type": "string",
"enum": [
"undefined",
"null",
"NaN"
]
},
"shoesizeLeft": {
"title": "Shoe size (left)",
"default": 42,
"type": "number"
},
"shoesizeRight": {
"title": "Shoe size (right)",
"default": 42,
"type": "number"
},
"attributes": {
"type": "object",
"title": "Attributes",
"required": [
"eyecolor"
],
"properties": {
"eyecolor": {
"type": "string",
"format": "color",
"title": "Eye color",
"default": "pink"
},
"haircolor": {
"type": "string",
"title": "Hair color"
},
"shoulders": {
"type": "object",
"title": "Shoulders",
"properties": {
"left": {
"type": "string",
"title": "Left"
},
"right": {
"type": "string",
"title": "Right"
}
}
}
}
},
"things": {
"type": "array",
"title": "I like...",
"items": {
"type": "string",
"enum": [
"clowns",
"compiling",
"sleeping"
]
}
},
"dislike": {
"type": "array",
"title": "I dislike...",
"items": {
"type": "string",
"title": "I hate"
}
},
"soul": {
"title": "Terms Of Service",
"description": "I agree to sell my undying <a href='https://www.youtube.com/watch?v=dQw4w9WgXcQ'>soul</a>",
"type": "boolean",
"default": true
},
"soulserial": {
"title": "Soul Serial No",
"type": "string"
},
"date": {
"title": "Date of party",
"type": "string",
"format": "date"
},
"radio": {
"title": "Radio type",
"type": "string",
"enum": [
"Transistor",
"Tube"
]
},
"radio2": {
"title": "My Second Radio",
"type": "string",
"enum": [
"Transistor",
"Tube"
]
},
"radiobuttons": {
"type": "string",
"enum": [
"Select me!",
"No me!"
]
}
}
}`
From first glance, it seems to generate an ID on the first input field. So I presume it is related to the Key in the form and the title in the Schema.
ID fields are generated from the last segment of the key in old 0.x versions and a combined form name and object path in the next version code for 1.0.0 and beyond.
So from 1.0.0 onward you will have proper unique ids like:
formName--objectName-arrayName-4-property
While a class matching that will also be available along with a version without array positions: formName--objectName-arrayName-property
The combination of unique id and flexible classes should cater to any customisation needs.
I have some problems with calling mixes in jade.
There is fragment of my layout:
section.page-content
if blocks && blocks.content
each blockProps, blockName in blocks.content
+blockName(blockProps)
I pass these params::
"blocks": {
"content": {
"menu": {
"items": [
{
"href": "href1",
"title": "title1",
"target": "target1",
"text": "text1"
},
{
"href": "href2",
"title": "title2",
"target": "target2",
"text": "text2"
}
]
},
"catalog_structure": {
"items": [
{
"text": "i1",
"href": "i1 href",
"title": "tit"
},
{
"text": "i2",
"href": "i2 href",
"title": "tit"
},
{
"text": "i3",
"href": "i3 href",
"title": "tit",
"items": [
{
"text": "i3_1",
"href": "i3_1 href",
"title": "tit"
},
{
"text": "i3_2",
"href": "i3_2 href",
"title": "tit"
}
]
},
{
"text": "i4",
"href": "i4 href",
"title": "tit"
}
]
},
}
}
And i want to call mixin with the name "blockName".
I tryed to call it in different ways.
Please, help me with my question.
Sorry for my poor english.
It is not possible.
visionmedia confirmed a year ago "it's not currently possible no"
Reference:
https://github.com/visionmedia/jade/issues/751