Tk::Tree::JSON - JSON tree widget
use Tk::Tree::JSON; $top = MainWindow->new; $json_tree = $top->JSON(?options?); $json_tree = $top->ScrolledJSON(?options?); $json_tree->load_json_file("file.json"); $json_tree->load_json_string( '[2008, "Tk::Tree::JSON", null, false, true, 30.12]');
JSON graphically displays the tree of JSON structures loaded from either a JSON file or a JSON string.
JSON enables Perl/Tk applications with a widget that allows visual representation and interaction with JSON structure trees.
Target applications may include JSON viewers, editors and the like.
JSON is a subclass of Tk::Tree and therefore inherits all of its standard options.
Details on standard widget options can be found at Tk::options.
Set the symbol representing JSON arrays.
Default value: [].
[]
Set the symbol representing JSON objects.
Default value: {}.
{}
Set the separator to add between names and values of JSON objects.
Default value: : .
:
Set the maximum number of characters to be displayed for JSON text values. Content of such values is trimmed to a length of valueMaxLength characters.
Default value: 80.
80
Set the symbol to append to JSON text values with length greater than valueMaxLength characters.
Default value: ....
...
The JSON method creates a widget object. This object supports the configure and cget methods described in Tk::options which can be used to enquire and modify the options described above. The widget also inherits all the methods provided by the generic Tk::Widget class.
An JSON is not scrolled by default. The ScrolledJSON method creates a scrolled JSON.
The following additional methods are available for JSON widgets:
Load a JSON structure from a file into the tree. If the tree is already loaded with a JSON structure, no reloading occurs and a warning message is issued.
Return value: none.
Example(s):
# load JSON structure from file document.json into the tree $json_tree->load_json_file('document.json');
Load a JSON structure represented by a string into the tree. If the tree is already loaded with a JSON structure, no reloading occurs and a warning message is issued.
# load JSON structure from json string into the tree $json_tree->load_json_string('{"name1": "text1", "name2": "text2"}');
For the currently selected element, retrieve the value of the underlying JSON structure according to the following logic:
JSON structure is either a string, number, true, false or null: full text content of JSON structure is retrieved
JSON structure is a name/value pair where value is neither a JSON array nor a JSON object: full text content of value is retrieved
JSON structure is none of the above: undef is retrieved
Return value: Full text content of JSON structure represented by selected element if it is either a string, number, true, false, null or a non-array non-object value of a name/value pair, or undef if it is either an array or object.
# retrieve value of currently selected element $value = $json_tree->get_value();
A JSON viewer using Tk::Tree::JSON can be found in the examples directory included with this module.
Tk::Tree::JSON version 0.01.
Santos, José.
Please report any bugs or feature requests to bug-tk-tree-json at rt.cpan.org or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Tk-Tree-JSON. The author will be notified and there will be automatic notification about progress on bugs as changes are made.
bug-tk-tree-json at rt.cpan.org
Documentation for this module can be found with the following perldoc command:
perldoc Tk::Tree::JSON
Additional information at:
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Tk-Tree-JSON
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Tk-Tree-JSON
CPAN Ratings
http://cpanratings.perl.org/d/Tk-Tree-JSON
Search CPAN
http://search.cpan.org/dist/Tk-Tree-JSON
Copyright (c) 2008 José Santos. All rights reserved.
This program is free software. It can redistributed and/or modified under the same terms as Perl itself.
Thanks to my family.
I dedicate Tk::Tree::JSON to Dr. Gabriel.
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in 'José.'. Assuming UTF-8
To install Tk::Tree::JSON, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tk::Tree::JSON
CPAN shell
perl -MCPAN -e shell install Tk::Tree::JSON
For more information on module installation, please visit the detailed CPAN module installation guide.