.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Data::HAL 3pm" .TH Data::HAL 3pm "2022-08-28" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Data::HAL \- Hypertext Application Language resource .SH "VERSION" .IX Header "VERSION" This document describes Data::HAL version 1.001 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 8 \& use Data::HAL qw(); \& use Data::HAL::Link qw(); \& { \& my $hal = Data::HAL\->from_json($json_str); \& my $resource_member_data_href = $hal\->resource; \& my $links_aref = $hal\->links; \& my $embedded_resources_aref = $hal\->embedded; \& } \& \& { \& my $hal = Data::HAL\->new( \& resource => {foo => 23, bar => 42}, \& links => [Data::HAL::Link\->new(relation => \*(Aqself\*(Aq, href => \*(Aq/\*(Aq)], \& ); \& \& my $json_str = $hal\->as_json; \& # { \& # "_links" : { \& # "self" : { \& # "href" : "/" \& # } \& # }, \& # "bar" : 42, \& # "foo" : 23 \& # } \& \& my @headers = $hal\->http_headers; \& # ( \& # \*(AqContent\-Type\*(Aq => \*(Aqapplication/hal+json\*(Aq, \& # \*(AqLink\*(Aq => \*(Aq;rel="self"\*(Aq \& # ) \& } .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\s-1HAL\s0 is a format you can use in your hypermedia \s-1API.\s0 .SS "Introduction" .IX Subsection "Introduction" This section is completely quoted from the specification: .PP There is an emergence of non-HTML \s-1HTTP\s0 applications (\*(L"Web APIs\*(R") which use hyperlinks to direct clients around their resources. .PP The \s-1JSON\s0 Hypertext Application Language (\s-1HAL\s0) is a standard which establishes conventions for expressing hypermedia controls, such as links, with \s-1JSON.\s0 .PP \&\s-1HAL\s0 is a generic media type with which Web APIs can be developed and exposed as series of links. Clients of these APIs can select links by their link relation type and traverse them in order to progress through the application. .PP \&\s-1HAL\s0's conventions result in a uniform interface for serving and consuming hypermedia, enabling the creation of general-purpose libraries that can be re-used on any \s-1API\s0 utilising \s-1HAL.\s0 .PP The primary design goals of \s-1HAL\s0 are generality and simplicity. \s-1HAL\s0 can be applied to many different domains, and imposes the minimal amount of structure necessary to cover the key requirements of a hypermedia Web \s-1API.\s0 .SS "Conformance" .IX Subsection "Conformance" The author claims to conform with , published 2013\-10\-03. .SH "INTERFACE" .IX Header "INTERFACE" .SS "Composition" .IX Subsection "Composition" None. .SS "Constructors" .IX Subsection "Constructors" \fI\f(CI\*(C`from_json\*(C'\fI\fR .IX Subsection "from_json" .PP .Vb 1 \& Data::HAL\->from_json($json_str) .Ve .PP Takes a \s-1HAL+JSON\s0 document as string and returns a \f(CW\*(C`Data::HAL\*(C'\fR object. .PP \fI\f(CI\*(C`new\*(C'\fI\fR .IX Subsection "new" .PP .Vb 4 \& Data::HAL\->new( \& resource => {foo => 23, bar => 42}, \& links => [Data::HAL::Link\->new(relation => \*(Aqself\*(Aq, href => \*(Aq/\*(Aq)] \& ) .Ve .PP Default Moo constructor, returns a \f(CW\*(C`Data::HAL\*(C'\fR object. .SS "Attributes" .IX Subsection "Attributes" \fI\f(CI\*(C`embedded\*(C'\fI\fR .IX Subsection "embedded" .PP Type \f(CW\*(C`ArrayRef[Data::HAL]\*(C'\fR, embedded resource objects .PP \fI\f(CI\*(C`links\*(C'\fI\fR .IX Subsection "links" .PP Type \f(CW\*(C`ArrayRef[Data::HAL::Link]\*(C'\fR, link objects .PP \fI\f(CI\*(C`resource\*(C'\fI\fR .IX Subsection "resource" .PP Type \f(CW\*(C`HashRef\*(C'\fR, member data representing the current state of the resource .PP \fI\f(CI\*(C`relation\*(C'\fI\fR .IX Subsection "relation" .PP Type Data::HAL::URI, identifier of the semantics of a link .PP Perl strings are coerced to the Data::HAL::URI type. .PP A stand-alone \s-1HAL+JSON\s0 document, when deserialised, will not have this attribute set in the root resource since nothing is linking to the document. .SS "Methods" .IX Subsection "Methods" \fI\f(CI\*(C`TO_JSON\*(C'\fI\fR .IX Subsection "TO_JSON" .PP Serialisation hook for the \s-1JSON\s0 (or compatible) module. .PP This method is not intended to be called directly from your code. Instead call \*(L"as_json\*(R" or \&\f(CW\*(C`JSON::to_json $hal, { convert_blessed => 1 }\*(C'\fR or similar. .PP \fI\f(CI\*(C`as_json\*(C'\fI\fR .IX Subsection "as_json" .PP Returns the resource object serialised as a \s-1HAL+JSON\s0 document string. .PP \fI\f(CI\*(C`http_headers\*(C'\fI\fR .IX Subsection "http_headers" .PP Returns a list of pairs of \s-1HTTP\s0 message headers. The keys are field name strings and the values are field content strings. \fBWarning\fR: since field names can repeat, assigning this list to a hash loses information. .PP The list is suitable as input for e.g. the \&\f(CW\*(C`headers\*(C'\fR accessor in HTTP::Headers or the \f(CW\*(C`headers\*(C'\fR attribute in Plack::Response. .PP \f(CW\*(C`Content\-Type\*(C'\fR .IX Subsection "Content-Type" .PP The value is \f(CW\*(C`application/hal+json\*(C'\fR, perhaps with a \f(CW\*(C`profile\*(C'\fR parameter. .PP \f(CW\*(C`Link\*(C'\fR .IX Subsection "Link" .PP See \*(L"as_http_link_value\*(R" in Data::HAL::Link. .SS "Exports" .IX Subsection "Exports" None. .SH "DIAGNOSTICS" .IX Header "DIAGNOSTICS" .ie n .SS """not a JSON object""" .el .SS "\f(CWnot a JSON object\fP" .IX Subsection "not a JSON object" The \*(L"from_json\*(R" constructor throws this exception of type \f(CW\*(C`failure::Data::HAL::InvalidJSON\*(C'\fR when the \s-1JSON\s0 input is a malformed \s-1HAL+JSON\s0 document. .SH "CONFIGURATION AND ENVIRONMENT" .IX Header "CONFIGURATION AND ENVIRONMENT" Requires no configuration files or environment variables. .SH "DEPENDENCIES" .IX Header "DEPENDENCIES" See meta file in the source distribution. .SH "INCOMPATIBILITIES" .IX Header "INCOMPATIBILITIES" None reported. .SH "BUGS AND LIMITATIONS" .IX Header "BUGS AND LIMITATIONS" Please report any bugs or feature requests to \f(CW\*(C`bug\-data\-hal@rt.cpan.org\*(C'\fR, or through the web interface at . .SS "tight coupling to \s-1JSON\s0" .IX Subsection "tight coupling to JSON" It is currently difficult to exert control over the specifics of (de)serialisation, perhaps put the (de)serialisers into attributes? .SS "error type is an attribute, not a class name" .IX Subsection "error type is an attribute, not a class name" It is not worth it to design an error class hierarchy for a single error. .SS "Data::HAL::URI::NamespaceMap is undocumented" .IX Subsection "Data::HAL::URI::NamespaceMap is undocumented" It is used only internally. .SH "TO DO" .IX Header "TO DO" .IP "make everything cache-friendly" 4 .IX Item "make everything cache-friendly" .PD 0 .IP "non-standard accessors for link objects" 4 .IX Item "non-standard accessors for link objects" .IP "support X8.3. cache pattern" 4 .IX Item "support X8.3. cache pattern" .IP "support \s-1HAL XML\s0" 4 .IX Item "support HAL XML" .PD .SH "SEE ALSO" .IX Header "SEE ALSO" AtomPub , the more mature, featureful hypermedia protocol .SH "AUTHOR" .IX Header "AUTHOR" Lars \s-1DXXXXXX\s0 \f(CW\*(C`\*(C'\fR .SH "LICENCE AND COPYRIGHT" .IX Header "LICENCE AND COPYRIGHT" Copyright X 2013\-2019 Lars \s-1DXXXXXX\s0 \f(CW\*(C`\*(C'\fR .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl 5.18.0. .SS "Disclaimer of warranty" .IX Subsection "Disclaimer of warranty" This library is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.