1. #1
    Sencha User
    Join Date
    Aug 2012
    Posts
    5
    Vote Rating
    0
    jesantana19 is on a distinguished road

      0  

    Default Answered: Problem retrieving JSON from Yahoo Pipes

    Answered: Problem retrieving JSON from Yahoo Pipes


    Hi i have a very similar problem to http://www.sencha.com/forum/showthre...P.request-does and after a lot of searching found this thread. I am tryin to access using a proxy to a Yahoo Pipes Json output. My code is as follow

    Code:
    Ext.Viewport.add(Ext.create('Ext.DataView', {
    
    			fullscreen: true,			store: {				autoLoad: true,				fields: [ 'fuente','texto'],												proxy: {					type: 'jsonp',					url: 'http://pipes.yahoo.com/pipes/pipe.run?_id=739242db9d5c22158ccc6ef85b588b0d&_render=json',																				reader: {						type: 'json',						encodeRequest: true,						rootProperty: 'value.items'					}				}			},			itemTpl: '<img src="{fuente}" /><h2>{texto}</h2>'				   }));


    It keeps giving me Uncaught SyntaxError: Unexpected token : in pipe.run 1

    I have tried cutting the json and creating an object in the console and it works well. I also change the url in order to fetch data from twitter api and also work. Seems that the problem is about pipes.

    Any help would be very appreciated. Thanks in advance!!!!

  2. There is a difference between JSONP and JSON... JSONP takes JSON and wraps it in a callback method to be executed but the response you are getting is just JSON so you will get an error.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,604
    Answers
    3450
    Vote Rating
    818
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    There is a difference between JSONP and JSON... JSONP takes JSON and wraps it in a callback method to be executed but the response you are getting is just JSON so you will get an error.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User
    Join Date
    Aug 2012
    Posts
    5
    Vote Rating
    0
    jesantana19 is on a distinguished road

      0  

    Default


    Thank you very much mitchell. With your help I solved the problem. The thing is that by specifying that my store uses jsonp, Sencha automatically added a callback to my url as I was able to see through Chrome. So it looks like http://pipes.yahoo.com/pipes/pipe.run?...&callback=Ext.data.JsonP.callback1

    But pipes expects its jsonp call to have as name _callback(with an uderscore before the name) as specified here
    http://pipes.yahoo.com/pipes/docs?do...leshooting#q12 so I added the parameter callbackKey: '_callback' to the proxy definition and all worked ok!!!! Thank you very much again

  5. #4
    Sencha User rabelanger's Avatar
    Join Date
    Jan 2010
    Location
    Montreal
    Posts
    15
    Vote Rating
    1
    rabelanger is on a distinguished road

      0  

    Default


    With the callback key set to '_callback', its working fine. Im having trouble mapping it in my jsonreader. The structure I get from yahoo pipes is
    Code:
    {
        value: {
            items:[{
                items:[{
                    ...
                }]
            }]
        }
    }
    Setting the jsonProperty to 'value.items.item' isn't doing it. Im guessing because the data is nested in arrays...How did you get it to work?
    rafael

  6. #5
    Sencha User
    Join Date
    Aug 2012
    Posts
    5
    Vote Rating
    0
    jesantana19 is on a distinguished road

      0  

    Default


    I do not have a second nested item. My structure is like

    Code:
    {
        value: {        items:[{            DATA        }]    } }
    so I put rootProperty: 'value.items' an it works fine. In your case I guess you should set the yours to rootProperty: 'value.items.items'