PURPOSE
========
To allow structured editing of JSON data. This version reads and
writes text files containing JSON data.
SECURITY
========
1. This system will only update files that already exist.
2. Also it will only look in one directory for files (see FPATH, line 49
of simpleserver.php)
3. You can only save a file you have first read with this program
4. Files that do not contain valid JSON and ONLY valid JSON cannot be
opened by this script.
There is no other security. Anyone who can access the script can
access any files in that directory (provided they contain valid JSON)
INSTALLATION
============
Unpack all the files in a directory accessible from your web server.
You will need a server running PHP7. It may work with PHP5 but this has
not been tested.
Make a directory somewhere for holding the JSON files. Your server needs
read write access to this folder.
Edit the FPATH value on line 49 of simpleserver.php to point to the
directory you just created.
Make one or more seed files in that directory. Seed files should just
contain {}.
USE
===
When you call up the script from your browser (JSONEdit.php) you should
get a drop down list of all the files in your JSON directory created
above. Select one to start editing it.
Your browser needs to be ECMAScript 6 complying. All recent browsers
should be but it has only been tested in Chromium Version 63.0.3239.84
(Official Build) Built on Ubuntu , running on LinuxMint 18.1 (64-bit)
so far.
There are buttons to collapse or expand nodes on the tree; and buttons
to add a new leaf node; to add a new branch; and to delete a leaf node or
branch. I am not very happy that these buttons are clear, but they all
have tooltips, so check the tooltip BEFORE you click one :-)
When you are done click the Save button. This will not close the window,
so click the Close button too. If you don't want to save, just click the
close button without the save button.
It is not obvious, but you can edit property names as well as property
values. Just double click the property name and edit it.
FILES
======
The pack contains the following files
simpleserver.php - this is the file that is called file XMLHttp to
provide the server side service needed
(get, put, list)
jsonedit.js - This file contains the code for converting JSON into
a DOMElement tree with all the needed behaviours
it can be used anywhere you want to place an editable
JSON based tree.
serverlink.js - provides Promise based services for communicating
with the server and waiting on document loaded.
JSONEdit.php - is not really a PHP file, just HTML. It uses the
other files to create a simple JSON Editor, and
provides an example of how to use them.
COPYRIGHT
==========
You are free to use this code anyway you want.
If you find ways to improve it, please do feed it back.
|