-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unions serialization. #61
Comments
Its also not understood, why simplified Union serialization (as a string value in case of void tag) is not really used (even in deserializers) in generated SDK code. |
The
Serializing
The compact union serialization format isn't understood by our client SDKs in any language besides Python because Dropbox server always sends down the more general form. That's done because we see the compact form as beneficial for writing requests by hand in a terminal, rather than for programmatic ease. Why do we support it in Python? Because Dropbox's API servers are written in Python and the deserializers needs to support the compact form for incoming client requests: https://github.com/dropbox/stone/blob/master/stone/backends/python_rsrc/stone_serializers.py#L642 Ideally, all of our deserializers would support the compact form, but I suspect that will only happen once we/someone requires the use of a target language other than Python on their server-side. |
Are you sure? It seems to me that .Net SDK serializes your example as:
I didn't run the code, but I reviewed it. I'll check it more... However, anyway, do unions has to inline struct fields or this is also only a compact format; for example, whether this:
have to be serialized to this:
or general form is also valid:
|
I'm certain that's our intended behavior. @qimingyuan can verify the .NET SDK. Unions have to inline struct fields, there's no compact/general form distinction. |
Ok, but what about structs with subtypes? To inline their fields inside a union still two ".tag" properties are required... |
Structs with subtypes cannot be inlined. Instead, the serialization looks just like the first nested union example I provided. Let me know if you want an example. |
By the way, thanks for the feedback. I've updated our documentation to be more explicit: https://github.com/dropbox/stone/blob/master/docs/json_serializer.rst#union Feel free to re-open if you have further questions. |
Please clarify somewhere how Union of Union is serialized. Also, how Union of Struct with subtypes is serialized.
As I undersnand, there should be several ".tag" properties in the same JSON object, which is not so easy to deduct.
The text was updated successfully, but these errors were encountered: