Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

APJSON

, 28 Aug 2013 CPOL
This is an alternative for "fastJSON"
Apolyton_FastJson_Binaries__v0.92_.zip
Output
Debug
Apolyton.FastJson.dll
Release x64
Apolyton.FastJson.dll
Release x86
Apolyton.FastJson.dll
consoletest.exe
consoletest.vshost.exe
consoletest.vshost.exe.manifest
fastJSON.dll
Release
Apolyton.FastJson.dll
Silverlight
Apolyton.Json.Silverlight.dll
Apolyton_FastJson_Binaries__v0.93_.zip
Apolyton.FastJson.dll
consoletest.exe
fastJSON.dll
Apolyton.FastJson.dll
consoletest.exe
consoletest.vshost.exe
fastJSON.dll
Apolyton.FastJson.dll
consoletest.exe
consoletest.vshost.exe
fastJSON.dll
Apolyton.FastJson.dll
consoletest.exe
fastJSON.dll
Apolyton.Json.Silverlight.dll
Apolyton_FastJson_Binaries__v0.9_.zip
Apolyton.FastJson.dll
Apolyton.FastJson.dll
consoletest.exe
consoletest.vshost.exe
consoletest.vshost.exe.manifest
fastJSON.dll
Apolyton.FastJson.dll
consoletest.exe
consoletest.vshost.exe
consoletest.vshost.exe.manifest
fastJSON.dll
Apolyton.FastJson.dll
consoletest.exe
consoletest.vshost.exe
fastJSON.dll
Apolyton_FastJson_Binaries__v1.0_.zip
Apolyton.FastJson.dll
consoletest.exe
consoletest.vshost.exe
consoletest.vshost.exe.manifest
fastJSON.dll
Apolyton.FastJson.dll
Apolyton.FastJson.pdb
consoletest.exe
consoletest.vshost.exe
fastJSON.dll
fastJSON.pdb
Apolyton.FastJson.dll
Apolyton.FastJson.pdb
consoletest.exe
consoletest.vshost.exe
fastJSON.dll
fastJSON.pdb
Apolyton.FastJson.dll
Apolyton.FastJson.pdb
consoletest.exe
fastJSON.dll
fastJSON.pdb
Apolyton.Json.Silverlight.dll
Apolyton.Json.Silverlight.pdb
apolyton_fastjson_sources__v0.92_.zip
Apolyton.FastJson
Apolyton.FastJson.csproj.user
Apolyton.FastJson.Silverlight.csproj.user
Apolyton.FastJson.v11.suo
Bin
Debug
Apolyton.Json.Silverlight.dll
Common
Data
Diagram.cd
obj
Debug
Apolyton.FastJson.dll
Apolyton.Json.Silverlight.dll
Release x64
Apolyton.FastJson.dll
Release x86
Apolyton.FastJson.dll
Release
Apolyton.FastJson.dll
Properties
Registry
Serialization
Apolyton.FastJson.Tests
bin
Release
Apolyton.FastJson.dll
Apolyton.FastJSON.Tests.dll
Data
Helpers
ComplexTypes
ParameterRelated
Polymorphism
RegistryHelpers
StandardTypes
obj
Debug
Apolyton.FastJSON.Tests.dll
build.force
Release (x86, CUSTOM TYPES)
build.force
Release
Apolyton.FastJSON.Tests.dll
Properties
Registry
Serialization
Console Test
bin
Debug
Apolyton.FastJson.dll
consoletest.exe
consoletest.vshost.exe
fastJSON.dll
DataObjects
obj
Debug
build.force
consoletest.exe
Release x64
consoletest.exe
Release x86
consoletest.exe
Release
build.force
consoletest.exe
Apolyton_FastJson_Sources__v0.93_.zip
Debug
Apolyton.FastJson.dll
Apolyton.FastJSON.Tests.dll
Apolyton.FastJson.dll
Apolyton.FastJSON.Tests.dll
Apolyton.FastJSON.Tests.dll
build.force
Apolyton.FastJSON.Tests.dll
Apolyton.FastJson.dll
consoletest.exe
consoletest.vshost.exe
fastJSON.dll
Release
Apolyton.FastJson.dll
consoletest.exe
fastJSON.dll
x86
Release (x86, CUSTOM TYPES)
Apolyton.FastJson.dll
consoletest.exe
fastJSON.dll
Release x64
Apolyton.FastJson.dll
consoletest.exe
fastJSON.dll
consoletest.exe
consoletest.exe
consoletest.exe
consoletest.exe
x86
Debug
consoletest.exe
Release x64
consoletest.exe
Release x86
consoletest.exe
Release
consoletest.exe
Apolyton.FastJson.csproj.user
Apolyton.FastJson.Silverlight.csproj.user
Apolyton.FastJson.v11.suo
Apolyton.Json.Silverlight.dll
Release
Apolyton.Json.Silverlight.dll
Diagrams
Json.cd
JsonParameters.cd
TypeDescriptors.cd
Apolyton.FastJson.dll
Apolyton.Json.Silverlight.dll
Apolyton.FastJson.dll
Apolyton.FastJson.dll
Apolyton.FastJson.dll
Apolyton.Json.Silverlight.dll
Apolyton_FastJson_Sources__v0.9_.zip
Apolyton.FastJson.csproj.user
Diagram.cd
Apolyton.FastJSON.Tests.dll
Apolyton.FastJSON.Tests.dll
build.force
consoletest.vshost.exe
consoletest.exe
consoletest.exe
consoletest.exe
consoletest.exe
Apolyton_FastJson_Sources__v1.0_.zip
Apolyton.FastJson.csproj.user
Apolyton.FastJson.Silverlight.csproj.user
Apolyton.FastJson.v11.suo
Apolyton.Json.Silverlight.dll
Apolyton.Json.Silverlight.pdb
Apolyton.Json.Silverlight.dll
Apolyton.Json.Silverlight.pdb
Json.cd
JsonParameters.cd
TypeDescriptors.cd
Apolyton.FastJson.csprojResolveAssemblyReference.cache
Apolyton.FastJson.dll
Apolyton.FastJson.pdb
Apolyton.Json.Silverlight.dll
Apolyton.Json.Silverlight.pdb
DesignTimeResolveAssemblyReferences.cache
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
Apolyton.FastJson.dll
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
Apolyton.FastJson.dll
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
Apolyton.FastJson.dll
Apolyton.Json.Silverlight.dll
Apolyton.Json.Silverlight.pdb
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
Apolyton.FastJson.dll
Apolyton.FastJson.pdb
Apolyton.FastJSON.Tests.dll
Apolyton.FastJSON.Tests.pdb
Apolyton.FastJson.dll
Apolyton.FastJson.pdb
Apolyton.FastJSON.Tests.dll
Apolyton.FastJSON.Tests.pdb
Apolyton.FastJson.Tests.csprojResolveAssemblyReference.cache
Apolyton.FastJSON.Tests.dll
Apolyton.FastJSON.Tests.pdb
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
build.force
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
Apolyton.FastJson.Tests.csprojResolveAssemblyReference.cache
Apolyton.FastJSON.Tests.dll
Apolyton.FastJSON.Tests.pdb
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
Apolyton.FastJson.dll
Apolyton.FastJson.pdb
consoletest.exe
consoletest.pdb
consoletest.vshost.exe
fastJSON.dll
fastJSON.pdb
Apolyton.FastJson.dll
Apolyton.FastJson.pdb
consoletest.exe
fastJSON.dll
fastJSON.pdb
Apolyton.FastJson.dll
Apolyton.FastJson.pdb
consoletest.exe
fastJSON.dll
fastJSON.pdb
Apolyton.FastJson.dll
Apolyton.FastJson.pdb
consoletest.exe
fastJSON.dll
fastJSON.pdb
consoletest.csprojResolveAssemblyReference.cache
consoletest.exe
consoletest.pdb
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
Release (x86, CUSTOM TYPES)
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
consoletest.csprojResolveAssemblyReference.cache
consoletest.exe
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
consoletest.csprojResolveAssemblyReference.cache
consoletest.exe
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
consoletest.csprojResolveAssemblyReference.cache
consoletest.exe
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
consoletest.csprojResolveAssemblyReference.cache
consoletest.exe
consoletest.pdb
DesignTimeResolveAssemblyReferencesInput.cache
TempPE
consoletest.csprojResolveAssemblyReference.cache
consoletest.exe
DesignTimeResolveAssemblyReferencesInput.cache
consoletest.csprojResolveAssemblyReference.cache
consoletest.exe
DesignTimeResolveAssemblyReferencesInput.cache
consoletest.csprojResolveAssemblyReference.cache
consoletest.exe
DesignTimeResolveAssemblyReferencesInput.cache
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Reflection;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using fastJSON;


namespace Tests
{
	#region

	[Serializable()]
	public class baseclass
	{
		public string Name { get; set; }
		public string Code { get; set; }
	}

	[Serializable()]
	public class class1 : baseclass
	{
		public class1() { }
		public class1(string name, string code, Guid g)
		{
			Name = name;
			Code = code;
			guid = g;
		}
		public Guid guid { get; set; }
	}

	[Serializable()]
	public class class2 : baseclass
	{
		public class2() { }
		public class2(string name, string code, string desc)
		{
			Name = name;
			Code = code;
			description = desc;
		}
		public string description { get; set; }
	}

	[Serializable()]
	public class colclass
	{
		public colclass()
		{
			items = new List<baseclass>();
			date = DateTime.Now;
			Ppp = @"
            AJKLjaskljLA
       ahjksjkAHJKS
       AJKHSKJhaksjhAHSJKa
       AJKSHajkhsjkHKSJKash
       ASJKhasjkKASJKahsjk
            ";
			gggg = Guid.NewGuid();
			//hash = new Hashtable();
			isNew = true;
			done= true;
		}
		public bool done { get; set; }
		public DateTime date {get; set;}
		//public DataSet ds { get; set; }
		public string Ppp { get; set; }
		public List<baseclass> items { get; set; }
		public Guid gggg {get; set;}
		public decimal? dec {get; set;}
		public bool isNew { get; set; }
		//public Hashtable hash { get; set; }

	}
	#endregion

	[TestFixture]
	public class mytests : TestFixtureBase
	{
		public mytests()
		{
			ds = CreateDataset();
			Console.WriteLine("count = " + count);
		}
		static DataSet ds;
		int count = 1000;
		
		[Test]
		public void a_new_serializer()
		{
			DateTime st = DateTime.Now;
			colclass c;
			string jsonText = null;
			c= CreateObject();
			for (int i = 0; i < count; i++)
			{
				jsonText = JSON.Instance.ToJSON(c);
			}
			//colclass deserializedStore = ServiceStack.Text.JsonSerializer.DeserializeFromString<colclass>(jsonText);
			//Console.WriteLine("Size = " + jsonText.Length);
			Console.WriteLine("time ms = " + DateTime.Now.Subtract(st).TotalMilliseconds);
		}
		
		[Test]
		public void b_new_deserializer()
		{
			DateTime st = DateTime.Now;
			colclass c;
			string jsonText = null;
			c= CreateObject();
			object o ;
			jsonText = JSON.Instance.ToJSON(c);
			for (int i = 0; i < count; i++)
			{
				o=JSON.Instance.ToObject(jsonText);
			}
			//colclass deserializedStore = ServiceStack.Text.JsonSerializer.DeserializeFromString<colclass>(jsonText);
			//Console.WriteLine("Size = " + jsonText.Length);
			Console.WriteLine("time ms = " + DateTime.Now.Subtract(st).TotalMilliseconds);
		}
		
		[Test]
		public void a_Stack_Serializer()
		{
			DateTime st = DateTime.Now;
			colclass c;
			string jsonText = null;
			c= CreateObject();
			for (int i = 0; i < count; i++)
			{
				jsonText = ServiceStack.Text.JsonSerializer.SerializeToString(c);
			}
			//colclass deserializedStore = ServiceStack.Text.JsonSerializer.DeserializeFromString<colclass>(jsonText);
			//Console.WriteLine("Size = " + jsonText.Length);
			Console.WriteLine("time ms = " + DateTime.Now.Subtract(st).TotalMilliseconds);
		}
		
		
		[Test]
		public void a_Lit_Serializer()
		{
			DateTime st = DateTime.Now;
			colclass c;
			string jsonText = null;
			c= CreateObject();
			for (int i = 0; i < count; i++)
			{
				jsonText = JSON.Instance.ToJSON(c);
			}
			//object deserializedStore = JsonMapper.ToObject(jsonText);
			//Console.WriteLine("Size = " + jsonText.Length);
			Console.WriteLine("time ms = " + DateTime.Now.Subtract(st).TotalMilliseconds);
		}

		[Test]
		public void a_nJson_Serializer()
		{
			DateTime st = DateTime.Now;
			colclass c;
			JsonSerializerSettings s = null;
			string jsonText = null;
			s = new JsonSerializerSettings();
			s.TypeNameHandling = TypeNameHandling.All;
			c= CreateObject();
			
			for (int i = 0; i < count; i++)
			{
				jsonText = JsonConvert.SerializeObject(c, Formatting.Indented, s);
			}
			//Console.WriteLine("Size = " + jsonText.Length);
			//colclass deserializedStore = (colclass)JsonConvert.DeserializeObject(jsonText, typeof(colclass), s);
			Console.WriteLine("time ms = " + DateTime.Now.Subtract(st).TotalMilliseconds);
		}


		[Test]
		public void b_nJson_DeSerializer()
		{
			DateTime st = DateTime.Now;
			colclass c;
			colclass deserializedStore = null;
			JsonSerializerSettings s = null;
			string jsonText = null;
			c= CreateObject();
			s = new JsonSerializerSettings();
			s.TypeNameHandling = TypeNameHandling.All;
			jsonText = JsonConvert.SerializeObject(c, Formatting.Indented, s);
			for (int i = 0; i < count; i++)
			{
				deserializedStore = (colclass)JsonConvert.DeserializeObject(jsonText, typeof(colclass), s);
			}
			//WriteObject(deserializedStore);
			Console.WriteLine("time ms = " + DateTime.Now.Subtract(st).TotalMilliseconds);
		}
		
		[Test]
		public void b_bin_DeSerializer()
		{
			DateTime st = DateTime.Now;
			colclass c;
			colclass deserializedStore= null;
			c= CreateObject();
			BinaryFormatter bf = new BinaryFormatter();
			MemoryStream ms = new MemoryStream();
			bf.Serialize(ms,c);
			
			for (int i = 0; i < count; i++)
			{
				ms.Seek(0L,SeekOrigin.Begin);
				deserializedStore =	(colclass)bf.Deserialize(ms);
			}
			//WriteObject(deserializedStore);
			Console.WriteLine("time ms = " + DateTime.Now.Subtract(st).TotalMilliseconds);
		}
		
		[Test]
		public void a_bin_Serializer()
		{
			DateTime st = DateTime.Now;
			colclass c;
			c= CreateObject();
			BinaryFormatter bf = new BinaryFormatter();
			MemoryStream ms = new MemoryStream();
			for (int i = 0; i < count; i++)
			{
				ms=new MemoryStream();
				bf.Serialize(ms,c);
			}
			//WriteObject(deserializedStore);
			//Console.WriteLine("Size = " + ms.Length);
			Console.WriteLine("time ms = " + DateTime.Now.Subtract(st).TotalMilliseconds);
		}
		
		[Test]
		public void b_Stack_DeSerializer()
		{
			DateTime st = DateTime.Now;
			colclass c;
			colclass deserializedStore= null;
			string jsonText = null;
			c= CreateObject();
			jsonText = ServiceStack.Text.JsonSerializer.SerializeToString(c);
			for (int i = 0; i < count; i++)
			{
				deserializedStore =	ServiceStack.Text.JsonSerializer.DeserializeFromString<colclass>(jsonText);
			}
			//WriteObject(deserializedStore);
			Console.WriteLine("time ms = " + DateTime.Now.Subtract(st).TotalMilliseconds);
		}
		
		public static colclass CreateObject()
		{
			var			c = new colclass();
			//c.ppp = "hello";
			//c.ds = ds;
			//c.hash.Add("pppp",new class1("1", "1", Guid.NewGuid()));
			//c.hash.Add(22,new class2("2", "2", "desc1"));
			c.done=true;
			c.items.Add(new class1("1", "1", Guid.NewGuid()));
			c.items.Add(new class2("2", "2", "desc1"));
			c.items.Add(new class1("3", "3", Guid.NewGuid()));
			c.items.Add(new class2("4", "4", "desc2"));
			return c;
		}
		
		[Test]
		public void b_Lit_DeSerializer()
		{
			DateTime st = DateTime.Now;
			colclass c;
			colclass deserializedStore=null;
			string jsonText = null;
			c= CreateObject();
			jsonText = JSON.Instance.ToJSON(c);
			for (int i = 0; i < count; i++)
			{
				deserializedStore =	(colclass)JSON.Instance.ToObject(jsonText);
			}
			//WriteObject(deserializedStore);
			Console.WriteLine("time ms = " + DateTime.Now.Subtract(st).TotalMilliseconds);
		}
		
		private void WriteObject(colclass obj)
		{
			foreach(object c in obj.items)
				;//Console.WriteLine(""+c.GetType());
		}
		
		public static DataSet CreateDataset()
		{
			DataSet ds = new DataSet();
			for (int j = 1; j < 3; j++)
			{
				DataTable dt = new DataTable();
				dt.TableName = "Table" + j;
				dt.Columns.Add("col1", typeof(int));
				dt.Columns.Add("col2", typeof(string));
				dt.Columns.Add("col3", typeof(Guid));
				dt.Columns.Add("col4", typeof(string));
				dt.Columns.Add("col5", typeof(bool));
				dt.Columns.Add("col6", typeof(string));
				dt.Columns.Add("col7", typeof(string));
				ds.Tables.Add(dt);
				Random rrr = new Random();
				for (int i = 0; i < 100; i++)
				{
					DataRow dr = dt.NewRow();
					dr[0] = rrr.Next(int.MaxValue);
					dr[1] = "" + rrr.Next(int.MaxValue);
					dr[2] = Guid.NewGuid();
					dr[3] = "" + rrr.Next(int.MaxValue);
					dr[4] = true;
					dr[5] = "" + rrr.Next(int.MaxValue);
					dr[6] = "" + rrr.Next(int.MaxValue);

					dt.Rows.Add(dr);
				}
			}
			return ds;
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Aron Kovacs

Germany Germany
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141223.1 | Last Updated 28 Aug 2013
Article Copyright 2012 by Aron Kovacs
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid