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

      0  

    Default Should Architect recognize this JsonP?

    [{"Id":1,"Name":"Tomato Soup","Category":"Groceries","Price":1.0},{"Id":2,"Name":"Yo-yo","Category":"Toys","Price":3.75},{"Id":3,"Name":"Hammer","Category":"Hardware","Price":16.99}]

    This is what I get back in Raw format from Fiddler. It's generated in asp.Net

    I'm using localhost to with the following link example localhost:58385/api/products/

    This generates the JsonP above. Is there something wrong with it for Architect because it doesn't display in the browser in a list.

  2. #2
    Sencha User aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,485
    Vote Rating
    135
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default

    The above is not JSONP. (It's actually not technically even JSON. JSON by definition has to have a top level object, not an array.)

    You can get this to work via a JsonReader with no rootProperty set on the reader. You probably need an AjaxProxy to grab data from your server (note it must be on the same server/protocol).
    Aaron Conran
    @aconran

  3. #3
    Sencha Premium Member
    Join Date
    Feb 2012
    Location
    Hillsborough, NC
    Posts
    374
    Vote Rating
    109
    worthlutz is a jewel in the rough worthlutz is a jewel in the rough worthlutz is a jewel in the rough

      1  

    Default

    Quote Originally Posted by aconran View Post
    ...(It's actually not technically even JSON. JSON by definition has to have a top level object, not an array.)...
    JSON can be an array: http://www.json.org/

    Worth

  4. #4
    Sencha User aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,485
    Vote Rating
    135
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default

    Quote Originally Posted by worthlutz View Post
    JSON can be an array: http://www.json.org/

    Worth
    You are correct and I was wrong in the statement above.

    From
    http://www.ietf.org/rfc/rfc4627.txt
    "A JSON text is a serialized object or array."
    Aaron Conran
    @aconran

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

      0  

    Default

    In that case, is there a way for Architect to recognise the JsonP output from Microsofts .Net Web API?

    I can get the data using an Ajax proxy but I need to get it cross domain - hence the JsonP.

  6. #6
    Sencha User aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,485
    Vote Rating
    135
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default

    Is it wrapped in a javascript function (the appropriate callback)?
    Aaron Conran
    @aconran

  7. #7
    Sencha User
    Join Date
    Aug 2012
    Posts
    81
    Vote Rating
    0
    heloWelo is on a distinguished road

      0  

    Default

    Quote Originally Posted by aconran View Post
    Is it wrapped in a javascript function (the appropriate callback)?
    Allegedly! Fiddler only seems to show the data but the new Web API is supposed to wrap it with the callback function.

    The Index (example .Net generated) page is also showing the data properly...

  8. #8
    Sencha User aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,485
    Vote Rating
    135
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default

    If its not wrapped in a javascript callback as specified via the url param, then its not JsonP.

    If you load it in the browser with the callback what does it show?
    Aaron Conran
    @aconran

Thread Participants: 2