SERNA .NET Serializer / Deserializer . Custom JSON Bytearray .
For .NET 4> and MONO

Discovery project, under development

Custom JSON-like serialization and deserialization implementation is ready.
It uses custom, JSON-like syntax (Serna-String).
Supports complex object structures: nested objects, arrays, nullable objects, dictionaries, hashsets etc.
Very fast.
Currently doesn't support datasets/datatables.
Bytearray serialization is in plan.

Example

using Serna;
 public class Mccsrv
        {
            public string ExternalH = null;         
            public ushort FreeSlots = 0;
            public string InternalH = string.Empty;
            public long Id = -1;
            public long Count = 0;
            public bool Automatic = true;
            public DateTime dt = new DateTime(2012, 12, 4, 12, 47, 45);
        }

        void Test
        {
            Mccsrv ser=new Mccsrv();
            ser.Automatic = false;         
            //Serialization
            string str = Serna.Serializers.SerializeToSernaString(ser);
            //or
            str = ser.SerializeToSernaString();
            //or
            str = Serna.Serializers.SerializeToSernaString(ser, new Serializers.SerializationSettings {  DateTimeFormat = Serializers.SerializationSettings.eDateTimeFormat.EuropeanVisual});

            //Result:            //{'ExternalHost':;'FreeSlots':'0';'InternalHost':'';'Id':'-1';'CustomersCount':'0';'AutomaticServer':'0';'dt':'04.12.2012 12:47:45 UTC+1';}

            //Deserialization
            ser = Serna.Serializers.DeserializeFromSernaString<Mccsrv>(str);
            //or
            ser = str.DeserializeFromSernaString<Mccsrv>();
            //or
            ser = str.DeserializeFromSernaString<Mccsrv>(new Serializers.SerializationSettings { DateTimeFormat = Serializers.SerializationSettings.eDateTimeFormat.EuropeanVisual })

            //Beautifying Serna-String
           Console.WriteLine(str.BeautifySernaString());

           //Result
/*
{
 'ExternalHost':;
 'FreeSlots':'0';
 'InternalHost':'';
 'Id':'-1';
 'CustomersCount':'0';
 'AutomaticServer':'0';
 'dt':'04.12.2012 12:47:45 UTC+1';
}
*/
        }


Or make it in following way:

            Dictionary<string, string> T1 = new Dictionary<string, string>();
            T1.Add("Ivan", "da Danilo");
            T1.Add("Belaya", "Kobila");
            string tstr = T1.SerializeToSernaString().BeautifySernaString();
            Console.WriteLine(tstr);
            T1 = tstr.DeserializeFromSernaString<Dictionary<string, string>>();
//Result:
/*
{
 'Ivan':'da Danilo';
 'Belaya':'Kobila';
}
*/

[04.06.2015]
var t = "{"p1":"113028906","p2": 12.485,"p3":{"ip1":34,"ip2":"dfs"},"p4":[{"ip1":33,"ip2":"fff"},"sdfs","dsfd"]}";

var re = t.DeserializeFromJsonStringToDictionary();
var x1 = re["p4"].DeserializeFromJsonStringToDictionary();
var x2 = x1.First().Key.DeserializeFromJsonStringToDictionary();

//when first is [-always array; {-new object

t.BeautifyJSONString();



serna.tiesky.com
hhblaze@gmail.com

Check out our DBreeze http://dbreeze.codeplex.com .NET NoSql database.

Last edited Jun 14, 2015 at 11:32 AM by hhblaze, version 23