Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm curious what solutions game developers have come up with for serializing the different types of data that they deal with for their games. Do you guys use some monolithic GameObject hierarchy that houses a serialization interface for derived types, use sort of custom RTTI-based solution, perform explicit stream serialization for certain classes, or use some of the open source solutions (boost::serialization, s11n, etc).

share|improve this question
1  
I think serialization in game development programming is an important topic, but I don't like this question. What are you trying to do? What specific problems are you trying to solve? In lieu of that, I converted it to a community wiki so that it's more of a discussion format. –  Tetrad Aug 5 '10 at 22:39
    
I think it would be good to apply some formating to this, (ala the version control question). –  Noctrine Aug 6 '10 at 17:08

5 Answers 5

up vote 8 down vote accepted

Protocol buffers from Google can be a pretty good approach for serializing c++ objects. You may have to make some intermediated objects as part of the serialization process, but it also works across many platforms and languages.

share|improve this answer
    
I'm using it and it's easy if you can automate the code generation in your build system. Although a really excellent advantage is that it allow you to transfer data on remote machnies without regarding the platform used, and it's optimized for that so the generated objects are not big. –  Klaim Oct 8 '10 at 12:22

We in our game simply use boost.serilization, it's easy to use and very fast, but it's in my opinion just useful for savegames. If you try creating characters, i recommend you something XML'ish or JSON based things, because they are easy to read and editable even if you don't have the editor.

share|improve this answer
    
I've seen boost::serialization used successfully for client/server communication as well. However, AFAIK it's stream-based, so it's not exactly version tolerant. That may not be a deal-breaker for client/server communication, but if you use it for saved games, then any change to the game data structures makes loading older saved games a virtual impossibility (support for loading older object versions becomes a real chore). –  Mike Strobel Aug 9 '10 at 18:16
    
@MikeStrobel I recently was reviewing a few serialization and json kits and came across this comment. boost::serialization explicitly supports versioning. The serialize calls can receive a version number and then it's up to the user to implement basic branching logic (if( version > 1.0)...). Overall seems pretty robust. –  M2tM Dec 24 '13 at 22:05

I rather like JSON for serialization. It is pretty simple to parse and there are free libraries available such as http://jsoncpp.sourceforge.net/ I've never been a fan of boost or RTTI in C++. Tinyxml also work well for xml serialization and deserialization. http://www.grinninglizard.com/tinyxml/ Ultimately I don't want to have to spend any more time than I have to for serialization.

share|improve this answer

XDS was designed just for this purpose, it gives you the benefits of XML during development and the benefits of a compact binary representation at distribution time.

share|improve this answer
    
I am not really sure what makes XDS different from Google Protocol Buffers? They seem to serve the same purpose, except that XDS was first. –  jacmoe Aug 6 '10 at 19:27

Both jsonCpp and Protocol buffers are good options. To my knowledge both are only going to allow you to serial tree structures out of the box (please correct me if I am wrong). boost::serialization can handle arbitrary graphs, but doesn't have a nice text format like json (I think there is an xml format)

Personally I think the approach for json serialization that Dojo has taken is the best
http://docs.dojocampus.org/dojox/json/ref

I made my own version of it in c++ using jsoncpp, that also will deserialize typed objects (I have sort of big factory for all my types). It allows me to make a scene from a collection of json files that can be referenced anyway I please.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.