In JSON-RPC 1.0, can a response object's "result" member be an Array? - json-rpc

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)

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.'.

Related

Is empty string value generally allowed by the FIX protocol?

When I look at the definition of a String type in the FIX protocol (e.g. here or here), I don't see a minimum length specified. Is it allowed to use empty strings? One online decoder seems to accept an empty string value (see tag 320), an other complains that it's invalid.
The FIX 4.4 specification states the following (emphasis in the original text):
Each message is constructed of a stream of <tag>=<value> fields with a
field delimiter between fields in the stream. Tags are of data type
TagNum. All tags must have a value specified. Optional fields without
values should simply not be specified in the FIX message. A Reject
message is the appropriate response to a tag with no value.
That strongly suggests (but does not unambiguously state) to me that the use of an empty value for a string is invalid. It is unsurprising to me that different FIX implementations might treat this edge case in different ways. So, I think the best approach is to avoid using empty values for strings.
+1 for Ciaran's and Grant's answer/comments. Just want to add something.
I generally suggest to look up things like this in the most current specification since they usually have been refined/reworded/clarified to eliminate unclear or ambiguous statements from older specs.
The answer is on the very page you link to in your question (emphasis mine, search for "Well-formed field"): https://www.fixtrading.org/standards/tagvalue-online/#field-syntax
A well-formed field has the form:
tag=value<SOH>
A field shall be considered malformed if any of the following occurs as a result of encoding:
the tag is empty
the tag delimiter is missing
the value is empty
the value contains an <SOH> character and the datatype of the field is not data or XMLdata
the datatype of the field is data and the field is not immediately preceded by its associated Length field.

Getting requested entity synonym rather than the reference value

When I do app.getArgument("ARGUMENT_NAME") it returns the reference value for synonym. How do I determine the requested synonym rather than the reference value?
If you look at the JSON, this used to be available in the "result"."parameters"."name.original" field, but that seems to have changed at some point.
Now you can find it in the parameters for any of the contexts. So if you are using JavaScript and have the JSON in a variable named "body" and the argument name in a variable named "name", you can probably evaluate something like
body.result.contexts[0].parameters[`${name}.original`]
to get the value you want.

XMLQUERY() WITHIN XMLATTRIBUTES()

I am doing some basic tasks using, sql/xml. I am currently working on an error message that I get when trying to compute a XMLQUERY() within a XMLATTRIBUTES() function. (See code below)
SELECT XMLELEMENT(NAME "Nodename",
XMLATTRIBUTES(XMLQUERY('$t//Element/text()' PASSING Info AS "t") AS "hello"))
FROM Kurs
The error message that I get, says that there is no qualified routine that can run the function. I cant copy-paste the error message because its in Swedish, but this should be enough.
Also this might help: SQLCODE=-440, SQLSTATE=42884, DRIVER=4.18.60
So my question is (I have been looking for the answer), why doesn't this work? I will always get a value from that XMLQUERY, and it should simply translate into a value and used by XMLATTRIBUTES()
Any documentation, or link, is welcomed as well!
Thank you in advance!
The scalar function XMLQUERY returns an XML value. The function XMLATTRIBUTES expects an expression that returns a value of any type, but XML and some other types.
Thus, the functions are not compatible the way you are using them. DB2 cannot find a routine with that function signature. It results in that error -440.
How about wrapping a CAST/XMLCAST around it...?

Interaction with enum members in swift-based app

I'm beginning to teach myself swift and I'm going through examples of games at the moment. I've run across a line of code that I thought was peculiar
scene.scaleMode = .ResizeFill
In languages I'm used to (C / Java) the "." notation is used to reference some sort of structure/ object but I'm not exactly sure what this line of code does as there is no specified object explicitly before the "."
Information regarding clarification of this non-specified "." reference, or when/ how it can be used, would be great
P.S. I'm using sprite kit in Xcode
In Swift, as in the other languages you mentioned, '.' is a member access operator. The syntax you are referring to is a piece of shorthand that Swift allows because it is a type-safe language.
The compiler recognises that the property you are assigning to is of type SKSceneScaleMode and so the value you are assigning must be one of that type's enumerated values - so the enumeration name can be omitted.
To add to PaulW11's answer, what's happening here is only valid syntax for enums, and won't work with any other type (class, struct, method, function). Swift knows the type of the property that you are assigning to is an enum of type SKSceneScaleMode, so lets you refer to the enum member without having to explicitly give the type of the enum (ie SKSceneScaleMode.ResizeFill).
There are some situations where there will be ambiguity, and you will have to give the full name, this will be dependant on the context. For example, you may have two different enum types in scope, that both have a matching member name.
EDIT
Updating this answers as I incorrectly specified this was only applicable to enums, which is not true. There is a good blog post here which explains in more detail
http://ericasadun.com/2015/04/21/swift-occams-code-razor/

PyArg_ParseTuple() on arbitrary tuples

I am looking for confirmation on this issue:
Can I use PyArg_ParseTuple() on any Python tuple, or just on those passed as argument lists from function calls?
I see strong indication for the former, but to my reading the documentation is rather vague on this point, hence my question here.
The only problem is that the error messages, if an error occurs while parsing the tuple, will be appropriate to a function call.
Otherwise, it should work on arbitrary tuples just as well as on argument lists.