José Santos > Tk-Tree-JSON > Tk::Tree::JSON

Download:
Tk-Tree-JSON-0.01.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  1
Open  0
View/Report Bugs
Module Version: 0.01   Source  

NAME ^

Tk::Tree::JSON - JSON tree widget

SYNOPSIS ^

 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]');

DESCRIPTION ^

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.

STANDARD OPTIONS ^

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.

WIDGET-SPECIFIC OPTIONS ^

Name: arraySymbol
Class: ArraySymbol
Switch: -arraysymbol

Set the symbol representing JSON arrays.

Default value: [].

Name: objectSymbol
Class: ObjectSymbol
Switch: -objectsymbol

Set the symbol representing JSON objects.

Default value: {}.

Name: nameValueSep
Class: NameValueSep
Switch: -namevaluesep

Set the separator to add between names and values of JSON objects.

Default value: : .

Name: valueMaxLength
Class: VALUEMaxLength
Switch: -valuemaxlength

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.

Name: valueLongSymbol
Class: VALUELongSymbol
Switch: -valuelongsymbol

Set the symbol to append to JSON text values with length greater than valueMaxLength characters.

Default value: ....

WIDGET METHODS ^

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:

$json_tree->load_json_file($json_filename)

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');
$json_tree->load_json_string($json_string)

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.

Return value: none.

Example(s):

 # load JSON structure from json string into the tree
 $json_tree->load_json_string('{"name1": "text1", "name2": "text2"}');
$json_tree->get_value()

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.

Example(s):

 # retrieve value of currently selected element
 $value = $json_tree->get_value();

EXAMPLES ^

A JSON viewer using Tk::Tree::JSON can be found in the examples directory included with this module.

VERSION ^

Tk::Tree::JSON version 0.01.

AUTHOR ^

Santos, José.

BUGS ^

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.

SUPPORT ^

Documentation for this module can be found with the following perldoc command:

    perldoc Tk::Tree::JSON

Additional information at:

COPYRIGHT AND LICENSE ^

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.

ACKNOWLEDGEMENTS ^

Thanks to my family.

DEDICATION ^

I dedicate Tk::Tree::JSON to Dr. Gabriel.

syntax highlighting: