The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

JSON::JOM::Node - represents a node in a JOM structure

DESCRIPTION

JOM nodes have the following built-in methods. Other methods are available in JOM plugins.

  • typeof - returns 'HASH', 'ARRAY', 'NULL', 'BOOLEAN', 'STRING', or 'NUMBER'

  • ref - returns 'HASH', 'ARRAY' or undef

  • toJSON - returns a JSON string representing the node. This is only a full valid JSON document if ref is defined.

  • rootNode - a reference to the root node of the JOM structure.

  • isRootNode - boolean; is this the root node of the JOM structure?

  • parentNode - a reference to the parent of this node in the JOM structure.

  • nodePath - a JSON::Path-compatible string pointing to this node within the JOM structure.

  • nodeIndex - the array index or object key of the parentNode where this node is located.

  • meta - returns a hashref containing metadata about this node. This is intended for use by plugins.

  • id - a string that identifies this node during a single execution context. This is intended for use by plugins.

Note, the following should always be true for any JOM node $this:

   $this->isRootNode
   or $this->parentNode->typeof eq 'ARRAY'
      && $this->parentNode->[ $this->nodeIndex ] == $this
   or $this->parentNode->typeof eq 'HASH'
      && $this->parentNode->{ $this->nodeIndex } == $this

BUGS

Please report any bugs to http://rt.cpan.org/.

SEE ALSO

JSON::JOM, JSON::JOM::Plugins.

JSON::JOM::Value, JSON::JOM::Array, JSON::JOM::Object.

AUTHOR

Toby Inkster <tobyink@cpan.org>.

COPYRIGHT

Copyright 2010-2011 Toby Inkster

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

DISCLAIMER OF WARRANTIES

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.