Viewing 15 replies - 1 through 15 (of 16 total)
  • Thread Starter therber2

    (@therber2)

    anyone?

    Plugin Author berkux

    (@berkux)

    Hi therber2,

    sorry I was busy on other projects.

    My first look ist that http://api.sportsdatabase.com/nfl/query.json?sdql=date%2Cpoints%40team%3DBears%20and%20season%3D2011&output=json&api_key=th926535
    gives a JSON that is starting with “json_callback”.
    Never had this before. I’ll check this, but it will take some days…

    Bernhard

    Plugin Author berkux

    (@berkux)

    Hi,

    http://api.sportsdatabase.com/nfl/query.json?sdql=date%2Cpoints%40team%3DBears%20and%20season%3D2011&output=json&api_key=YOUR_API_KEY
    gives in serveral way invalid JSON in the sense I can’t handle this with standard methods.
    First the feed starts with “json_callback”. I do not know what’s the purpose of that. JSON-decoding is not possible with my plugin yet.
    Second: At ‘date’ etc. single quotes are used. With JSON double quotes are expected.
    See http://jsonlint.com/ for errors.

    So what can we do? One way would be removing the “json_callback” and replacing single by double quotes. Then we’d have JSON…

    Best
    Bernhard

    Thread Starter therber2

    (@therber2)

    “So what can we do? One way would be removing the “json_callback” and replacing single by double quotes. Then we’d have JSON…”

    I agree. I’ve contacted the source and will see if I can callup a json without that prefix.

    In an example of his own, however, the creator shows an example where the use of single quotes isn’t an issue: http://sportsdatabase.com/api

    Thread Starter therber2

    (@therber2)

    Hi Bernhard,

    I wasn’t able to get the site issuing the api to help come up with a work around.

    Is it possible to do an update on the plugin that will ignore the ‘json_callback’ prefix and interpret single quotes as double?

    I’ll send over a nice PP donation…

    Best,
    Tom

    Plugin Author berkux

    (@berkux)

    Hi Tom,

    ok, I’ll work on that. Please wait until I decided if this is a feature of the free or pro-version.
    This is also even if I remove the prefix there is some problem interpreting the valid json data.
    Hopefully tomorrow I’ll have an answer onm that.

    Bernhard

    Plugin Author berkux

    (@berkux)

    Hi Tom,

    i’m sorry to write: My plugin can’t work with tihs JSON, even if it’s made valid. My JSPN-Parser requires named arrays, not numbered. I tried to fix this in my plugin (either free and PRO), but I do have no idea yet on how to do this with my template-syntax now. Afer hundreds of JSONs this is the first time… Sorry about that.

    I accept this challange, but can’t work on it the next time.
    Therefore for this special JSON another plugin I see two ways:
    Either you find another Plugin. Or I or someone else creates a special Plugin for that which is independent of my parser. This wil ltake some time, and I would do this only as a payed project.

    Best
    Bernhard

    Thread Starter therber2

    (@therber2)

    Hmm. Thanks Bernhard. The person who issues that api was surprised to see that we’re having trouble and gave a few examples of people using it for example:

    (Same json link above) — The following code used to display what you see on this page: http://sportsdatabase.com/api?test=12

    A minimal example of the API for the SDQL <em>date,points@team=Bears and season=2011</em><div id='content'>SportsDatabase.com Content</div>
    <script>
    function get_query(data){
        $('#content').html('Loading data from http://SportsDatabase.com');
        $.getJSON('http://api.sportsdatabase.com/nfl/query.json?jsoncallback=?',data,
                function(result)
                {
                   $('#content').html('the first header you requested is <b>'+result.headers[0] + ' </b>which has a first group first value of<b> '+result.groups[0].columns[0][0] + '</b>');
                });}
    get_query({'api_key': 'p11nF2a3dAk254au', 'host': 'sportsdatabase.com', 'client': 'guest', 'test': 12, 'output': 'json', 'login_message': '', 'sport': 'nfl', 'sdql': 'date,points@team=Bears and season=2011'});
    </script>
    Thread Starter therber2

    (@therber2)

    At the moment, I don’t have much time, by the way, to develop and new slate plugin for you to work on unfortunately and I don’t know of any other similar WP plugins that decode json.

    Thread Starter therber2

    (@therber2)

    By the way, in the code above (‘<script> function get_query…’), I wanted to ask:

    1. What code is he using? Appears to be HTML, PHP and jquery
    2. What code is your plugin using to display / publish the user input?

    I think if the two matchup, we could get to the bottom of this fairly easily! 🙂

    Plugin Author berkux

    (@berkux)

    Hi,

    as I’m currently busy in building a special custom-version of the plugin please forgive the delay. Hopefully on friday I’ll check you comments.

    Bernhard

    Thread Starter therber2

    (@therber2)

    Not to worry. I appreciate the consideration and we’re all busy. This one is a bit of a puzzle.

    Plugin Author berkux

    (@berkux)

    The above code is another way to get the data on your website: The JSON-feed is fetched on runtime by jQuery/ajax and displayed by JavaScript/jQuery.
    This is ok, but different to my way:
    As jQuery/ajax gets the data at the cleint by JS, there is no SEO-relevant content on the displaying website. If you do not need that and JS-unable clients are negligible this way is very good.
    But if you want the data as HTML on your website my plugin is doing that. This was the initial reason for my plugin…

    Plugin Author berkux

    (@berkux)

    http://api.sportsdatabase.com/nfl/query.json?jsoncallback=?
    might work with jQuery-getJSON, but not with json_decode
    http://php.net/manual/de/function.json-decode.php

    To get this working you must remove “?(” at the start and “);” at the end.

    so: “The person who issues that api was surprised” gets another surprise…

    Thread Starter therber2

    (@therber2)

    Hmmm. Looks interesting. Do you have an example of a table using that jQuery-getJSON?

Viewing 15 replies - 1 through 15 (of 16 total)

The topic ‘JSON-Decoding failed Error’ is closed to new replies.