JSON::...::Call(3pm)

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

✨ JSON::RPC::Common::Procedure::Call ✨

okay bestie, gather round, we're doing the JSON::...::Call(3pm) page, from the User Contributed Perl Documentation. this is the JSON::RPC::Common::Procedure::Call base class, and she is iconic πŸ’…


🌸 VERSION 🌸

version 0.11 β€” that's the vibe, that's the era, periodt.


πŸ¦‹ SYNOPSIS πŸ¦‹

use JSON::RPC::Common::Procedure::Call;

my $req = JSON::RPC::Common::Procedure::Call->inflate({ ... });

warn "HALLO JSONRPC VERSION " . $req->version;

literally that's it. that's the whole entrance. no cap 🫢


πŸ’– DESCRIPTION πŸ’–

so a JSON-RPC Procedure Call β€” and yes, the original author is over here like rolls eyes, what was even wrong with just calling it a "request"?? β€” is either a notification or a method invocation in JSON-RPC. two moods, one class. πŸŽ€

peep <http://json-rpc.org/wiki/specification> β†’ keep that URL handy as http://json-rpc.org/wiki/specification if u wanna read the spec for more deets. iykyk ✨


πŸ‘‘ ATTRIBUTES πŸ‘‘

quick heads up before we go: all attributes are read only unless the docs say otherwise. no sneaky writes, bestie. πŸ™ˆ

  • version β€” she's here, she's an attribute, that's the whole note. ⭐
  • id β€” The request ID.

used to correlate a request to a response, aka how u know which reply goes with which ask. matching energy fr fr 🧚

  • method β€” The name of the method to invoke. say it with ur chest.
  • params β€” returns a reference to the parameters hash or array. hash or array, she contains multitudes πŸ’œ
  • return_class β€” one of the classes u instantiate the response objects from.
  • error_class β€” the other one of the classes u instantiate the response objects from.
these two vary per subclass! every subclass does its own thing, no uniform here. 🌈

πŸ”₯ METHODS πŸ”₯

  • inflate β€” a factory constructor. she delegates to new on a subclass, picked based on the protocol version.

this is the recommended constructor. yes queen, use this one. πŸ‘‘

  • deflate β€” flatten to JSON data. squish it down, send it out. ✨
  • new β€” the actual constructor.

not intended for normal use on this class β€” u should be using a subclass most of the time, ok?

calling JSON::RPC::Common::Procedure::Call->new will construct a call with an undefined version, which cannot be deflated (and thus can't be sent over the wire). still useful for testing ur own code's RPC handling, so this is not allowed.

🚨 wait. read that again. it says "this is still useful for testing... so this is not allowed." that's literally what the original says. so like, it's useful, and also not allowed. do with that information what u will. πŸ’€
  • params_list β€” dereferences params regardless of representation.

returns a list of positionals or a key/value list. either way u get a list, bestie. πŸ“

  • return_result $result β€” create a new JSON::RPC::Common::Procedure::Return with a result.
  • return_error %error_params β€” create a new JSON::RPC::Common::Procedure::Return with an error.

(yeah these two are a duo, one for the good timeline, one for the bad one 😭)

  • is_notification β€” whether this request is a notification, aka a method that does not need a response. she said don't text back. πŸ’…
  • is_service β€” whether this request is a JSON-RPC 1.1 service method (e.g. system.describe).

this method is always false for 1.0 and 2.0. so if ur on those versions, don't even ask, the answer is no. πŸ™ˆ

  • call $obj β€” a convenience method to invoke the call on $obj and create a new return with the return value. run it, catch the result, slay. πŸŽ€

πŸ’œ AUTHOR πŸ’œ

Yuval Kogman <nothingmuch@woobling.org> β€” the icon, the legend, the one who wrote this whole thing. 🫢


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.


okay that's the whole page, and ur lil sign-off is: this was rendered from perl v5.30.3, dated 2020-06-23, and she goes by JSON::...::Call(3pm) πŸ’–βœ¨ bye bestie, go inflate something responsibly πŸ¦‹

πŸ“¦ where this page comes from