xmlrpc icon indicating copy to clipboard operation
xmlrpc copied to clipboard

fix array parsing when one element is without type identifier and not null

Open aler9 opened this issue 6 years ago • 0 comments

Hello, this is another fix, unrelated to #67, that allows to parse this response:

<value><array><data>
  <value>A</value>
</data></array></value>

when using as receiver:

&[]interface{}{}

The problem here is that the library, when dealing with arrays, instantiates an object of the same type of the array for each element, so in this case it instantiates an interface{} for each element.

An interface{} can receive a string, but only if the type identifier is specified, ie:

<value><string>Once upon a time</string></value>

This patch allows an interface{} to receive a string even when the type identifier is absent, ie:

<value>Once upon a time</value>

PS: if you're wondering what kind of software/protocol is producing these horrendous responses, it's the Robot Operating System (ROS) (https://www.ros.org/)

aler9 avatar Nov 11 '19 21:11 aler9