I’ve added a simple If Switch so the user can choose between JSON and XML. Ideally the workflow should automatically detect the file format, but without some actual XML data I’m not sure to approach the problem.
Hub Link to my Solution for challenge 12… Get request through loop while switch node / part answer is missing as i couldnt find how to identify the file on xml or json basis to parse.
Very cool API!
Kodo’s to who formulated to challenge. The small detail of handling xml encoded response forced me to add a whole loop around the data parsing section.
@martinmunch
IF Switches have two output ports and come in different flavours:
The Empty Table Switch bypasses the main branch when the input table is empty (no rows)
The Java IF allows to write arbitrary Java code the decide which branch to activate (it has access to Flow Variables only – I wish it would also know about table dimensions)
The IF Switch can be set up statically, or be controlled by a Flow Variable
The Case Switches allow any number of branches, and any data type. The output can be set up statically, or be controlled by a Flow Variable. So it’s kinda the big brother of the “normal” IF Switch. I have never used a Case Switch so far though, so I might not be 100% accurate about them.
In short: The abnormal IF Switches come in handy in situations, where a Case Switch would require helper nodes to produce the same behaviour.
PS: I should mention that the Case Switches got an overhaul with KNIME AP 4.5. Before that, they had a fixed number of 3 output ports and were limited to Flow Variables and Tables I think. So me not using them is force of habit, but that will fade
We let the user decide what parsing route to take (XML or JSON) based on a manual checking of the response type. We saw a few fully automated solutions here that look amazing too!
As always, thanks for engaging in our weekly challenges and for the high quality of the solutions!.
Hi y’all !
A rather late submission but here it is.
A simple approach to decide whether the response is an XML or a JSON, using the Content type response header (application/xml; charset=utf-8 or application/json; charset=UTF-8).
This parser would admit any of those options and decide how to parse the corresponding output. At the end, it will concatenate both parsed branches. In this case we don’t have any XML response so we can only check the output of the json parser.