SYNOPSIS

  # NOTE: this is not an end-user package,
  # see TM::Materialized::JTM for common application patterns

  # reading JSON/YAML:
  my $tm=TM->new(...);
  Class::Trait->apply($tm,"TM::Serializable::JTM");
  $tm->deserialize($jsondata);

  # writing JSON/YAML:
  # ...a map $tm is instantiated somehow

  Class::Trait->apply($tm,"TM::Serializable::JTM");
  my $yamltext=$tm->serialize(format=>"yaml");

DESCRIPTION

This trait provides functionality for reading and writing Topic Maps in \s-1JTM\s0 (\s-1JSON\s0 Topic Map) format, as defined here: http://www.cerny-online.com/jtm/1.0/ <http://www.cerny-online.com/jtm/1.0/>.

Limitations:

  • Variants are not supported by \s-1TM\s0.

  • Reification of basenames, occurrences and roles is not supported by \s-1TM\s0.

  • Multiple scopes are not supported by \s-1TM\s0.

INTERFACE

Methods

deserialize

This method take a string and parses \s-1JTM\s0 content from it. It will raise an exception on any parsing error. On success, it will return the map object. The method understands one key/value parameter pair:

  • format (choices: "json", "yaml") This option controls whether the \s-1JTM\s0 is expected to be in \s-1JSON\s0 format or in \s-1YAML\s0 (which is a superset of \s-1JSON\s0). If no format parameter is given but the TM::Materialized::JTM trait is used, then the format is inherited from there; otherwise the default is "json".

serialize

This method serializes the map object in \s-1JTM\s0 notation and returns the result as a string. The method understands one key/value parameter pair:

  • format (choices: "json", "yaml") This option controls whether the \s-1JTM\s0 result should be created in the \s-1JSON\s0 format or in \s-1YAML\s0 (which is a superset of \s-1JSON\s0). If no format parameter is given but the TM::Materialized::JTM trait is used, then the format is inherited from there; otherwise the default is "json".

RELATED TO TM::Serializable::JTM…

\s-1TM\s0, TM::Serializable

AUTHOR INFORMATION

Copyright 2010, Alexander Zangerl, All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. http://www.perl.com/perl/misc/Artistic.html