0

a dot notation question

I want to know what is the proper dot notation for this table in yql
http://developer.yahoo.com/yql/console/#h=...ections.updates

when you get results from it by dot notation?

I tried to get the count with this notation,obj.data.query.count, but obviously, i am wrong.

by
4 Replies
  • Hi!

    I guess you mean a query like 'select * from social.connections.updates where guid=me',

    I'll assume that you are using json and javascript, so that means that obj.data.query.results is an array, you just have to ask for the length of that array: obj.data.query.results.length

    Cheers!
    Francisco.

    QUOTE (Houyhnhnm @ Nov 11 2010, 08:19 AM) <{POST_SNAPBACK}>
    I want to know what is the proper dot notation for this table in yql
    http://developer.yahoo.com/yql/console/#h=...ections.updates

    when you get results from it by dot notation?

    I tried to get the count with this notation,obj.data.query.count, but obviously, i am wrong.
    0
  • QUOTE (arcturus @ Nov 11 2010, 08:35 AM) <{POST_SNAPBACK}>
    Hi!

    I guess you mean a query like 'select * from social.connections.updates where guid=me',

    I'll assume that you are using json and javascript, so that means that obj.data.query.results is an array, you just have to ask for the length of that array: obj.data.query.results.length

    Cheers!
    Francisco.


    thanks francisco,
    I should have just used that, but i still am not getting the output in my code.

    This is the javascript in my CDATA section, I don't know what could be wrong with it

    var returnstr1="";

    function cb1(obj)
    {
    if(obj.data){
    var index=0;
    var countsize=obj.data.query.results.length;
    while(index<countsize)
    {
    returnstr1=returnstr1.concat("<p>entry",index,"</p>");
    index++;
    }
    }

    }

    function toQueryString(obj) {
    var parts = [];
    for(var each in obj) if (obj.hasOwnProperty(each)) {
    parts.push(encodeURIComponent(each) + '=' +
    encodeURIComponent(obj[each]));
    }
    return parts.join('&');
    }


    function runQuery(query, handler) {
    var BASE_URI = 'http://query.yahooapis.com/v1/yql';
    gadgets.io.makeRequest(BASE_URI, handler, {
    METHOD: 'POST',
    POST_DATA: toQueryString({q: query, format: 'json'}),
    CONTENT_TYPE: 'JSON',
    AUTHORIZATION: 'OAuth'
    });
    }

    function initfunc(){
    runQuery('select * from flickr.photos.search where has_geo="true" and text="san francisco"',cb1);
    document.getElementById('yap-notice2').innerHTML = "<table><tr><td>"+returnstr1+"</td></tr></table>";


    }
    0
  • Can you verify that your variable ┬┤returnstr1' is modified?

    Actually you should write this code:
    CODE
    document.getElementById('yap-notice2').innerHTML = "<table><tr><td>"+returnstr1+"</td></tr></table>";


    at last statement of your function 'cb1'.

    Cheers,
    Francisco.

    QUOTE (Houyhnhnm @ Nov 13 2010, 09:11 AM) <{POST_SNAPBACK}>
    thanks francisco,
    I should have just used that, but i still am not getting the output in my code.

    This is the javascript in my CDATA section, I don't know what could be wrong with it

    var returnstr1="";

    function cb1(obj)
    {
    if(obj.data){
    var index=0;
    var countsize=obj.data.query.results.length;
    while(index<countsize)
    {
    returnstr1=returnstr1.concat("<p>entry",index,"</p>");
    index++;
    }
    }

    }

    function toQueryString(obj) {
    var parts = [];
    for(var each in obj) if (obj.hasOwnProperty(each)) {
    parts.push(encodeURIComponent(each) + '=' +
    encodeURIComponent(obj[each]));
    }
    return parts.join('&');
    }


    function runQuery(query, handler) {
    var BASE_URI = 'http://query.yahooapis.com/v1/yql';
    gadgets.io.makeRequest(BASE_URI, handler, {
    METHOD: 'POST',
    POST_DATA: toQueryString({q: query, format: 'json'}),
    CONTENT_TYPE: 'JSON',
    AUTHORIZATION: 'OAuth'
    });
    }

    function initfunc(){
    runQuery('select * from flickr.photos.search where has_geo="true" and text="san francisco"',cb1);
    document.getElementById('yap-notice2').innerHTML = "<table><tr><td>"+returnstr1+"</td></tr></table>";


    }
    0
  • QUOTE (arcturus @ Nov 14 2010, 08:08 AM) <{POST_SNAPBACK}>
    Can you verify that your variable ┬┤returnstr1' is modified?

    Actually you should write this code:
    CODE
    document.getElementById('yap-notice2').innerHTML = "<table><tr><td>"+returnstr1+"</td></tr></table>";


    at last statement of your function 'cb1'.

    Cheers,
    Francisco.


    thanks:) I actually finally got the code to work, as I would like.
    It took longer than I hoped but I finally made examples where I extract updates and create updates for users.
    Now, I go forward more in control and understanding

    thank you again for at least, caring enough to respond
    0

Recent Posts

in YQL