How to call jade mixin by name? - javascript

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

Related

How to add "collection" field to metadata for Solana NFTs with Visual Studio Code

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 }
]
}
}

How to read contacts info from Google with jQuery?

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;
});

Dynamic Hierarchical Router in JavaScript Framework Router

We had settled on using Aurelia as a JS framework, but hit a wall with routing. We have hierarchical navigation, which Aurelia Router does not support (https://github.com/aurelia/router/issues/90).
Navigation also depends on who is logged in, and each path from the primary navigation can have 1, 2 or 3 levels. Here is a sample of what we are doing now using knockoutjs (we are moving to a SPA): http://jsfiddle.net/22dy9yqw/4/. The data source for the navigation has to be a nested JSON object that represents the navigational structure, and the UI has to remain as is (bottom level is a dropdown). Here is an example of our structure:
[
{
"name": "No SubNav",
"href": "\/no-subnav",
"id": "no-subnav"
},
{
"name": "Settings",
"href": "\/settings\/",
"id": "settings",
"children": [
{
"name": "Setting1",
"href": "\/settings\/setting1\/",
"id": "setting1"
}, {
"name": "Setting2",
"href": "\/settings\/setting2\/",
"id": "setting2"
}
]
},
{
"name": "Reports",
"href": "\/reports\/",
"id": "reports",
"children": [
{
"name": "Section1",
"href": "\/reports\/section1\/",
"id": "section1",
"children": [
{
"name": "Section1 Report1",
"href": "\/reports\/section1\/report1",
"id": "report1-1",
}, {
"name": "Section1 Report2",
"href": "\/reports\/section1\/report2",
"id": "report1-2",
}, {
"name": "Section1 Report3",
"href": "\/reports\/section1\/report3",
"id": "report1-3",
}
]
}, {
"name": "Section2",
"href": "\/reports\/section2\/",
"id": "section2",
"children": [
{
"name": "Section2 Report1",
"href": "\/reports\/section2\/report1",
"id": "section2-1",
}, {
"name": "Section2 Report2",
"href": "\/reports\/section2\/report2",
"id": "section2-2",
}, {
"name": "Section2 Report3",
"href": "\/reports\/section2\/report3",
"id": "section2-3",
}, {
"name": "Section2 Report4",
"href": "\/reports\/section2\/report4",
"id": "section2-4",
}, {
"name": "Section2 Report5",
"href": "\/reports\/section2\/report5",
"id": "section2-5",
}
]
}
]
}
]
Can something like this be done easily with Aurelia while still taking advantage of other Router functionality (e.g., mapping)? Is there a better solution? I am new to the JS framework world and am a bit overwhelmed.

Adding IDs to Angular Schema Form's Input Fields?

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.

Accessing data in json?

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.

Categories