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.
- 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.
- 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.
- 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!