Using a set to serialize ItemFlags in CraftMetaItem causes serialized items to only be storable in YAML format.

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: Minor
    • None
    • Affects Version/s: None

      At line 699 of this commit a Set is used to transform ItemFlags into a form that should be suitable for serialization. When the data is serialized into YAML this works out fine because YAML supports sets natively. However, JSON does not support sets natively and serializing to JSON format causes the data to be malformed. Many other data formats also do not support sets natively and would likely have similar issues.

      There seems to be no good reason to actually use a set in the serialized data when a list would work just as well. A YAML set doesn't prevent a user from adding a duplicate entry to the serialized data. When deserializing the data, a Set could be used to ensure any duplicates in the serialized data don't get translated to duplicate ItemFlags. One could argue that the set notation in the serialized YAML data shows intent. While true, the majority of the users dealing with this data won't have a clue as to what that means.

      Using a Set only on deserialization seems to be the better option. It would achieve the same purpose (aside from displaying intent) while not causing issues for non-YAML data formats when serializing.

            Assignee:
            Unassigned
            Reporter:
            Jeremy Wood
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: