x


binary serialization in c#

I'm looing for solution how to serialize and de serialize binary data. I want to use BJON (Binary JSON), but i can change my decision, so i found that solution - http://james.newtonking.com/archive/2009/12/26/json-net-3-5-release-6-binary-json-bson-support.aspx . Is it works in unity or now? What you can recommend me for me?

more ▼

asked Mar 30 at 11:34 AM

Andrew Cherkashin\'s gravatar image

Andrew Cherkashin
53 6 6 15

If it requires 3.5, likely not yet. Why not try it?

Mar 30 at 01:29 PM Ricardo
(comments are locked)
10|3000 characters needed characters left
 moderation talk

3 answers:

Or if you are willing to decorate the objects you are serializing with attributes, and you're not serializing anything stored as just "object", you could try protobuf-net (Google Protocol Buffers). It is faster and serialized objects take up less space than using BinaryFormatter.

more ▼

answered Aug 21 at 04:32 PM

SharedProphet\'s gravatar image

SharedProphet
41 2

protobuf-net is awesome! doesn't work on unity iOS though.

edit: protobuf-net v2 beta is out. I've been using it on iOS and works fantastic.

Feb 24 at 04:27 PM mindlube
(comments are locked)
10|3000 characters needed characters left
 moderation talk

You should look into the .NET-specific class BinaryFormatter (MSDN). It will binary-serialize any ISerializable object for you.

more ▼

answered Mar 30 at 04:34 PM

SpikeX\'s gravatar image

Blah
10.4k 40 74 155

(comments are locked)
10|3000 characters needed characters left
 moderation talk

Also if you want to serialize Unity objects you can try using ISerializationSurrogate

http://msdn.microsoft.com/en-us/library/system.runtime.serialization.iserializationsurrogate.aspx

I used it to serialize MonoBehaviours as they dont need to be created when you deserialize. You just serialize the name( or unique id ) of the game object that owns your MonoBehaviour script and then use GameObject.Find when you deserialize.

more ▼

answered Dec 14 at 07:53 PM

Zeanog\'s gravatar image

Zeanog
1

(comments are locked)
10|3000 characters needed characters left
 moderation talk
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x223
x96
x29
x20

Asked: Mar 30 at 11:34 AM

Seen: 2695 times

Last Updated: Aug 02 at 01:22 AM

powered by Qato - Enterprise Q&A