Title: JSON-Decoding failed Error
Last modified: August 30, 2016

---

# JSON-Decoding failed Error

 *  Resolved [therber2](https://wordpress.org/support/users/therber2/)
 * (@therber2)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/json-decoding-failed-error/)
 * First off, I have the plugin installed correctly and given examples work fine.
   The json I’m trying to import from is coming up with an error.
 * Here is the api: [http://api.sportsdatabase.com/nfl/query.json?sdql=date%2Cpoints%40team%3DBears%20and%20season%3D2011&output=json&api_key=th926535](http://api.sportsdatabase.com/nfl/query.json?sdql=date%2Cpoints%40team%3DBears%20and%20season%3D2011&output=json&api_key=th926535)
 * Here is the short code I am using just to try and get around the initial error(“
   JSON-Decoding failed. Check structure and encoding if JSON-data. problems with
   JSON-structure: check basenode-param”)
 *     ```
       [jsoncontentimporter url="http://api.sportsdatabase.com/nfl/query.json?sdql=date%2Cpoints%40team%3DBears%20and%20season%3D2011&output=json&api_key=th926535" numberofdisplayeditems="30" basenode=""]
       text
       [/jsoncontentimporter]
       ```
   
 * Is there a problem in general with the source or something like that?
 * Thanks a bunch. I’ll donate!
    -Tom
 * [https://wordpress.org/plugins/json-content-importer/](https://wordpress.org/plugins/json-content-importer/)

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

1 [2](https://wordpress.org/support/topic/json-decoding-failed-error/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/json-decoding-failed-error/page/2/?output_format=md)

 *  Thread Starter [therber2](https://wordpress.org/support/users/therber2/)
 * (@therber2)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/json-decoding-failed-error/#post-6648995)
 * anyone?
 *  Plugin Author [berkux](https://wordpress.org/support/users/berkux/)
 * (@berkux)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/json-decoding-failed-error/#post-6649039)
 * 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](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](https://wordpress.org/support/users/berkux/)
 * (@berkux)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/json-decoding-failed-error/#post-6649045)
 * Hi,
 * [http://api.sportsdatabase.com/nfl/query.json?sdql=date%2Cpoints%40team%3DBears%20and%20season%3D2011&output=json&api_key=YOUR_API_KEY](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/](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](https://wordpress.org/support/users/therber2/)
 * (@therber2)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/json-decoding-failed-error/#post-6649049)
 * “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](http://sportsdatabase.com/api)
 *  Thread Starter [therber2](https://wordpress.org/support/users/therber2/)
 * (@therber2)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/json-decoding-failed-error/#post-6649086)
 * 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](https://wordpress.org/support/users/berkux/)
 * (@berkux)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/json-decoding-failed-error/#post-6649087)
 * 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](https://wordpress.org/support/users/berkux/)
 * (@berkux)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/json-decoding-failed-error/#post-6649088)
 * 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](https://wordpress.org/support/users/therber2/)
 * (@therber2)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/json-decoding-failed-error/#post-6649105)
 * 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](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](https://wordpress.org/support/users/therber2/)
 * (@therber2)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/json-decoding-failed-error/#post-6649106)
 * 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](https://wordpress.org/support/users/therber2/)
 * (@therber2)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/json-decoding-failed-error/#post-6649107)
 * 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](https://wordpress.org/support/users/berkux/)
 * (@berkux)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/json-decoding-failed-error/#post-6649108)
 * 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](https://wordpress.org/support/users/therber2/)
 * (@therber2)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/json-decoding-failed-error/#post-6649109)
 * Not to worry. I appreciate the consideration and we’re all busy. This one is 
   a bit of a puzzle.
 *  Plugin Author [berkux](https://wordpress.org/support/users/berkux/)
 * (@berkux)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/json-decoding-failed-error/#post-6649113)
 * 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](https://wordpress.org/support/users/berkux/)
 * (@berkux)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/json-decoding-failed-error/#post-6649114)
 * [http://api.sportsdatabase.com/nfl/query.json?jsoncallback=](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](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](https://wordpress.org/support/users/therber2/)
 * (@therber2)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/json-decoding-failed-error/#post-6649115)
 * Hmmm. Looks interesting. Do you have an example of a table using that jQuery-
   getJSON?

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

1 [2](https://wordpress.org/support/topic/json-decoding-failed-error/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/json-decoding-failed-error/page/2/?output_format=md)

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

 * ![](https://ps.w.org/json-content-importer/assets/icon-256x256.png?rev=3464653)
 * [Get Use APIs - JSON Content Importer](https://wordpress.org/plugins/json-content-importer/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/json-content-importer/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/json-content-importer/)
 * [Active Topics](https://wordpress.org/support/plugin/json-content-importer/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/json-content-importer/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/json-content-importer/reviews/)

 * 16 replies
 * 2 participants
 * Last reply from: [berkux](https://wordpress.org/support/users/berkux/)
 * Last activity: [10 years, 6 months ago](https://wordpress.org/support/topic/json-decoding-failed-error/page/2/#post-6649116)
 * Status: resolved