If both the serializer and deserializer have access to the Sitecore database, you can easily create a wrapper that simply serializes the identifier, database name, version, and language. Then, when deserializing at the other end, you can reselect the same Sitecore element from the database using this information.
If the deserializer does not have access to the database at all, it really depends on your data usage needs. I usually item.Fields.ReadAll() over all the fields (remember to use item.Fields.ReadAll() ) and save them in the dictionary for easy access. For serialization, I convert this to a pair of List<T> values ββand ignore the Dictionary member (since it cannot be serialized), and then re-populates it with deserialization. I also save several other properties, such as ID, language, version, template, path, etc.
Alternatively, if you create an entire library of model classes so that each template is mapped to a class (some people do this), you can (possibly) serialize these strings since they (probably) are no longer bound to the Sitecore item.
Matt
source share