Web JSON Editor: Create data values in JSON format interactively

Recommend this page to a friend!
  Info   View files Example   View files View files (10)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 51 All time: 498 This week: 1Up
Version License JavaScript version Categories
jsoneditor 1.0.0Freely Distributable6AJAX, Data types
Description Author

This package can be used to create data values in JSON format interactively.

It provides a Web based user interface to edit data value that will be composed to generate a JSON string that represents that value.

The package can save the edited JSON value to a server by sending an AJAX request to a given URL. An example of server side script to handle saving on the server is provided in PHP.

Picture of Chris Jeffries
Name: Chris Jeffries <contact>
Classes: 2 packages by
Country: United Kingdom
Age: 74
All time rank: 1728 in United Kingdom
Week rank: 34 Up2 in United Kingdom Up

To allow structured editing of JSON data. This version reads and
writes text files containing JSON data.

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)

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 {}.

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.

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.                   
You are free to use this code anyway you want. 

If you find ways to improve it, please do feed it back.
  Files folder image Files  
File Role Description
Accessible without login Image file collapse.png Icon button image
Accessible without login Image file delete.png Icon button image
Accessible without login Image file expand.png Icon button image
Accessible without login Image file insert.png Icon button image
Accessible without login Image file inserttree.png Icon button image
Plain text file jsonedit.js Class Primary library
Accessible without login Plain text file JSONEdit.php Example Example file showing use
Accessible without login Plain text file README Doc. Documentation
Accessible without login Plain text file serverlink.js Aux. JS to promisify XMLHttp
Accessible without login Plain text file simpleserver.php Aux. server for example

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:498
This week:1Up