JSON::...Return(3pm)

πŸ“¦
version 0.11 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– JSON::RPC::Common::Procedure::Return πŸ’–

okay bestie, welcome to the manual page for JSON::RPC::Common::Procedure::Return β€” yes that's the whole name, it's a Perl module, and it's the JSON-RPC procedure return class. She's giving "the thing that comes back after you ask for something" energy. ✨


🌸 VERSION 🌸

This is version 0.11. Lowkey iconic. πŸ‘‘


πŸ¦‹ SYNOPSIS πŸ¦‹

here's the vibe, fr fr:

use JSON::RPC::Common::Procedure::Return;

# create a return from a call, retaining the ID
my $return = $call->return_result("foo");

# inflate gets a version specific class
my $return = JSON::RPC::Common::Procedure::Return->inflate(
        version => "2.0",
        result  => "foo",
        id      => $id,
);

# you can specify a return with an error, it's just an attribute
my $return = JSON::RPC::Common::Procedure::Return->new(
        error => ...,
);

not me writing three whole different ways to make one object 😭 she contains multitudes.


πŸŽ€ DESCRIPTION πŸŽ€

So this class abstracts JSON-RPC procedure returns β€” aka the results. That's the whole gig. 🫢

And yes, version specific implementations are provided as well, so whatever version you're on, she's got a subclass for you. no cap.


✨ ATTRIBUTES ✨

  • id β€” the ID of the call this is a result for. 🏷️
heads up bestie: results with no ID are typically error results for parse fails, back when the call ID could never be determined. like, we never even got her name. πŸ’€
  • result β€” the JSON data that is the result of the call, if any. πŸ“
  • error β€” the error, if any. This is a JSON::RPC::Common::Procedure::Return::Error object (or a version specific subclass). 😭
  • error_class β€” the error class to use when instantiating errors. ✨

πŸ’… METHODS πŸ’…

  • inflate
  • deflate

these two go to and from JSON data. main character round-trip energy. πŸ”₯

  • inflate_error
  • deflate_error

helpers for managing the error sub object. little sidekicks, love them for that. 🧚

  • set_error β€” calls create_error with it's arguments and sets the error to that.

E.g.

$res->set_error("foo");
$res->error->message; # "foo"

the way that "foo" comes right back out. ate. πŸ’…

  • create_error β€” instantiate a new error of class error_class using new_dwim in JSON::RPC::Common::Procedure::Return::Error. πŸ‘‘

🌈 AUTHOR 🌈

Yuval Kogman <nothingmuch@woobling.org> β€” shoutout to the legend. 🫢


This software is copyright (c) 2014 by Yuval Kogman and others.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. 🌸


and that's the whole page bestie!! this was rendered with perl v5.30.3, dated 2020-06-23 β€” yes she's a little vintage but she still serves. mwah πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from