Closed isaacwein closed 1 year ago
This library doesn't support ignoring fields with -
like encoding/json
does. Adding support would technically be a backwards incompatible change, but I'd be surprised if anyone was actually affected. @kolo thoughts?
Why would it be a backward incomparable how can you usexmlrpc”-“
at all?
Or may you can add a new suffix like xmlrpc=“,ignore”
On Sun, Sep 18, 2022 at 7:39 PM Ilia Choly @.***> wrote:
This library doesn't support ignoring fields with - like encoding/json does. Adding support would technically be a backwards incompatible change, but I'd be surprised if anyone was actually affected. @kolo https://github.com/kolo thoughts?
— Reply to this email directly, view it on GitHub https://github.com/kolo/xmlrpc/issues/81#issuecomment-1250411999, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIIO4JDNX65MQD7H7C6SNVDV66RZ3ANCNFSM6AAAAAAQPTS6CE . You are receiving this because you authored the thread.Message ID: @.***>
Currently, if you define a struct with a -
field tag, it will use -
as the field name in the generated xml:
For example:
type S struct {
Name string `xmlrpc:"-"`
}
Will encode like this:
<value><struct><member><name>-</name><value><string>test</string></value></member></struct></value>
So adding support for -
can potentially change the behaviour of existing code. In practice, I think that's very unlikely. I'm leaning towards simply adding support for -
.
Ok, thanks for the clarification.
As of the JSON standard
As a special case, if the field tag is "-", the field is always omitted. Note that a field with name "-" can still be generated using the tag "-,".
i think if a tag isxmlrpc:"-,"
the key should be <name>-</name>
like json, not <name>-,</name>
comma is a special character it is used for additional info about the tag xmlrpc:"key,omitempty"
thanks alot for adding support for this it helped a lot
the xmlrpc encoder is throwing an error on ignored fields
xmlrpc_test.go:23: err: xmlrpc encode error: unsupported type
playground