0

Section 1.2 of the JSON-RPC 1.0 specification says, "result - The Object that was returned by the invoked method. This must be null in case there was an error invoking the method."

This suggests that the result should be either an Object or null. However, the examples in Section 4 show results that are Strings or Numbers.

I presume that the spec authors intended for all types (including Arrays) to be allowed, and that Section 1.2 is written wrongly. Is there an authoritative source that can confirm or refute this?

(Side note: The v2.0 specs are better, albeit still a bit ambiguous. Section 5 simply says "The value of this [result] member is determined by the method invoked on the Server" but at least the examples do show an Array as a result)

JKSH
  • 2,658
  • 15
  • 33

1 Answers1

1

Returning any json value ( including arrays) is fine per the specification.

The phrasing is a bit poor on that part... should have been 'value' instead of 'object'. Reading into it, the wording and speculating.... "object" in the way it is written refers to what is being returned as result of invocation... rather than a 'json object' that is returned on the wire... think 'string object, array object, etc.'.

  • That's what I presumed, too. I don't suppose there's an authoritative source that confirms this? – JKSH Aug 02 '16 at 14:45
  • 3
    Authoritative source.... not as such. Base it on the various implementations and the examples in the spec(s). I was involved in the 2.0 spec, and host both json-rpc specification sites... if that helps add weight to my answer. (updated my profile). Feel free to pose the question to the community group: https://groups.google.com/forum/#!forum/json-rpc – Matt Morley - MPCM Aug 07 '16 at 00:42