Closed ahoward1024 closed 8 months ago
Hi @ahoward1024 ,
Thanks for reaching out regarding this. I think it's a fairly new use-case I haven't heard of before. Typically when working with XML-RPC you have a knowledge of the struct field names, however in your case - as you said, you do not. What you need is a way to handle a struct as a map.
I took a stab at prototyping how this could be achieved and will likely open a PR fairly soon, however I'm still thinking about how to handle this in the best way from the compatibility perspective.
@ahoward1024 I've pushed the PR for this fix. Could you please give it a try by pulling the dev branch into your go.mod?
You can do this by running
go get -u alexejk.io/go-xmlrpc@decode-struct-as-map
It should give you a pseudo-version dependency entry, something like:
alexejk.io/go-xmlrpc v0.4.2-0.20240214200317-abbf585c7d64
In order to solve your issue you should be able to now do something like this:
type Data struct {
Map map[string][][]DataType
}
You can check out the added tests for more details.
@alexejk Apologies, I've been traveling and just got back to this.
I've pulled in your changes and they work flawlessly for our purpose. Thank you for getting back to me so quickly on this! :rocket:
I'll go ahead an close this out!
Thanks for confirming, @ahoward1024 ! I've merged the PR and just triggered the 0.5.0 release. You can swap over to that version shortly (effectively just let it pull the latest version instead).
Hi, I'm struggling to decode an XMLRPC example where there are is a struct with a number of members whose names are arbitrary, so I can't put them into a tag.
Example XML
```The following structure can be successfully decoded into:
However, I cannot know the names where
TESTING1
andTESTING2
are. They will change at runtime and the dataset will get added to and removed from, so those values are essentially arbitrary and therefore cannot be written directly into the struct. I also don't have control over the RPC API, so I cannot change the structure.Any help would be greatly appreciated.