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::Plugins::TreeUtils - add tree methods

DESCRIPTION

This JOM plugin adds the following method to JOM objects and arrays:

  • hasDescendent($x) - returns true if $x is a descendent of the current node.

  • hasChild($x) - returns true if $x is a direct child of the current node. This should be faster than looping through values.

  • getDescendentsByType($type) - list of descendent nodes where typeof is $type. $type may be '*'. Returns results in depth-first order.

  • getChildrenByType($type) - list of child nodes where typeof is $type. $type may be '*'.

It adds the following method to all JOM nodes:

  • hasAncestor($x) - returns true if $x is an ancestor of the current node.

BUGS

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

SEE ALSO

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

AUTHOR

Toby Inkster <tobyink@cpan.org>.

COPYRIGHT

Copyright 2010 Toby Inkster

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