quick-xml icon indicating copy to clipboard operation
quick-xml copied to clipboard

Nested Struct and Enum Serialization

Open dbcfd opened this issue 5 years ago • 5 comments
trafficstars

This PR fixes issues with nested struct and enum serialization, where the struct name will be serialized multiple times, or enum name will serialized. Unit variant enums are supported as well.

dbcfd avatar Jan 05 '20 17:01 dbcfd

Found a couple more issues with added test cases, will be adjusting this branch more.

dbcfd avatar Jan 06 '20 01:01 dbcfd

This PR fixes the bug I'm seeing with nested struct names getting duplicated, but it leaves in several debugging println! statements that render it unusable until fixed. :-)

(annotation) Start: Fields=[]
(folder) Pending: Fields=[Some("annotation")]```

dave-andersen avatar Mar 29 '20 20:03 dave-andersen

Does this fix flatten and untagged enums?

EDIT: According to my tests this doesn't seem to fix flatten. What exactly does this fix?

Ten0 avatar Mar 31 '20 17:03 Ten0

See the test cases added as part of this PR. Without this PR, those test cases will fail.

I no longer am working on the project with the dataset that led to this PR, so would recommend at least bringing in the test cases from this PR, and improving the implementation to make those tests pass. This PR is one possible implementation, but there's probably a better implementation.

dbcfd avatar Apr 02 '20 14:04 dbcfd

Should we maybe still try to merge it? I'm sure I wouldn't be alone to benefit from the serde support working better :) (Currently I'm using this PR, without the prints and merged on master: https://github.com/Ten0/quick-xml but I'd much rather not have to maintain this)

Ten0 avatar Apr 02 '20 17:04 Ten0

Since merging #490 both problems are fixed:

  • struct name no more serialized multiple times
  • enum name is not serialized. Type names are no more serialized at all

Mingun avatar Oct 29 '22 10:10 Mingun