Support » Plugin: wpDataTables - WordPress Data Table, Dynamic Tables & Table Charts Plugin » Nested JSON has a query parameters bug

  • Resolved vedante30

    (@vedante30)


    First of all I want to say that this is a gret plugin!
    Thank you for creating it!
    I have found a small bug on the full version of the plugin.
    I have tried the free version and the “nested JSON” option was working perfectly,
    When i started to use the full version, “nested JSON” stop accepting query parameters in “Input JSON URL” field. I get “Error! Unable to retrieve results” when I click “Get JSON roots” or “Conflict Error” when I click Save changes.
    Example of JSON URL:
    https://data.gov.il/api/3/action/datastore_search?resource_id=2de7b543-e13d-4e7e-b4c8-56071bc4d3c8&limit=1000
    https://prnt.sc/ToYMoCA_Ph69
    https://prnt.sc/aUE1qjc8FS8g
    When I delete the query parameter (&limit=1000) from the URL, it works fine.
    What i already tried:
    1) Different JSON API urls
    2) Different Server / localhost
    2) Disabling other plugins
    Please check why the query parameters are not accepted on the full version.
    Thanks in advance!

    • This topic was modified 1 year, 2 months ago by vedante30.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author wpDataTables

    (@wpdatatables)

    Hello, @vedante30
    Since you’re using the Premium version of the plugin, please open a ticket in the “Pre-Purchase” section on our official support platform, and we’ll gladly help you there.

    Premium products are not supported in these forums, as per this comment by WordPress.org moderators.

    Thank you for understanding.

    Thread Starter vedante30

    (@vedante30)

    I have found a ready to use solution for that issue (Till the PRO plugin will be fixed).
    Putting it here if anybody with same issue will need it.

    Add this code in your functions.php theme file:

    add_action( 'parse_request', 'simplify_nested_json', 0 );
    function simplify_nested_json( $wp ) {
        // Check if the request is /simplify-json
        if ( 'simplify-json' !== $wp->request ) {
            return;
        }
    $url ='https://data.gov.il/api/3/action/datastore_search?resource_id=2de7b543-e13d-4e7e-b4c8-56071bc4d3c8&limit=3000';
    $JSON = file_get_contents($url);
    // echo the JSON (you can echo this to JavaScript to use it there)
    // You can decode it to process it in PHP
    $data = json_decode($JSON);
        // Array version of the JSON data.
        // Send headers.
        status_header( 200 );
        nocache_headers();
        header( 'Content-Type: application/pkcs7-mime' );
        // And serve the JSON data.
         echo wp_json_encode($data->result->records );
        exit;
    }

    This code turns the nested JSON to a flat one.
    * Change the $url with your required API URL.
    * Change this part $data->result->records with the rout to the requested part of the JSON
    * Add https://yoursite.com/simplify-json “Input JSON URL” field.

    • This reply was modified 1 year, 2 months ago by vedante30.
    • This reply was modified 1 year, 2 months ago by vedante30.
    Plugin Author wpDataTables

    (@wpdatatables)

    Hi, vedante30
    Thank you for sharing your solution on the Forum for other users.
    We are aware of this, and our developers will fix this issue for the premium version in the next update.
    The Lite version does not have this issue.
    Thanks again for sharing your workaround with us.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Nested JSON has a query parameters bug’ is closed to new replies.