browse by category or date

Five years ago, I created JSON Table Editor. Recently I have the time to revisit the project and do some minor bug fixes and enhancements.

  1. Array editing.
    In previous version, loading an array of string will give you a table of characters. This is embarrassingly wrong.

    The updated version has no more of this problem.

  2. Improvements on multi-level object editing.
    I changed the button title from ‘Save to Upper Level’ to ‘Finish Editing’, which is more appropriate. I also make the window closed when you click ‘Finish Editing’ button. I also show the updated JSON so we can notice the changes.

    The changes also propagated all the way to the top. In previous version, on each child-window we need to click the ‘Save to Upper Level’ button.
  3. Limiting the proxy
    The proxy in the previous version is just a dumb proxy. It fetches any url requested and dump whatever content. I see a potential misuse here. So I limit the proxy to only fetch JSON, CSV and raw/text content.

    <?php
    $qUrl = $_REQUEST["q"];
    // create a new cURL resource
    $ch = curl_init();
    // set the URL
    curl_setopt($ch, CURLOPT_URL, $qUrl);
    // get only the Head
    curl_setopt($ch, CURLOPT_NOBODY, true);
    // curl_exec return value instead of directly to out
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    // do the request
    $res = curl_exec($ch);
    // check the content type
    $contentType = curl_getinfo ($ch, CURLINFO_CONTENT_TYPE);
    //only accept json, csv
    curl_close($ch);
     
    //error_log($contentType);
     
    if (strpos($contentType,'/json')!== false || strpos($contentType, '/csv')!== false || strpos($contentType, 'text/plain')!== false)
    {
       // ... SNIP ...
       // Normal CURL processing
    }
    else {
       //error_log('Not JSON');
       echo "Invalid resource. We only retrieve JSON/CSV/text resource. The requested URL returned ".$contentType;
    }
    ?>
    

That’s all, folks! Looking forward to hear your thoughts. Cheers!

GD Star Rating
loading...
Bug Fixes and Enhancements to JSON Table Editor, 3.0 out of 5 based on 1 rating

Possibly relevant:

About Hardono

Howdy! I'm Hardono. I am working as a Software Developer. I am working mostly in Windows, dealing with .NET, conversing in C#. But I know a bit of Linux, mainly because I need to keep this blog operational. I've been working in Logistics/Transport industry for more than 11 years.

Incoming Search

javascript, json, php

1 Trackback

 

No Comment

Add Your Comment