From b8c178cfc1d439bd16d0205510f3a4feacaba965 Mon Sep 17 00:00:00 2001 From: James Dennes Date: Wed, 10 Nov 2010 18:38:36 +1100 Subject: [PATCH] Demonstration of how json serialisation works nicely using the Newtonsoft.Json library for .NET 2.0. --- ConsoleRunner/Program.cs | 2 +- createsend-dotnet/General.cs | 4 +- createsend-dotnet/createsend-dotnet.csproj | 8 + createsend-dotnet/lib/Newtonsoft.Json.XML | 990 +++++++++++++++++++++ createsend-dotnet/lib/Newtonsoft.Json.dll | Bin 0 -> 73728 bytes 5 files changed, 1002 insertions(+), 2 deletions(-) create mode 100755 createsend-dotnet/lib/Newtonsoft.Json.XML create mode 100755 createsend-dotnet/lib/Newtonsoft.Json.dll diff --git a/ConsoleRunner/Program.cs b/ConsoleRunner/Program.cs index cf89bf2..efa1ec5 100755 --- a/ConsoleRunner/Program.cs +++ b/ConsoleRunner/Program.cs @@ -11,7 +11,7 @@ static void Main(string[] args) { foreach(string country in General.Countries()) Console.WriteLine(country); - + Console.ReadLine(); } } } diff --git a/createsend-dotnet/General.cs b/createsend-dotnet/General.cs index 1ea1998..b516629 100755 --- a/createsend-dotnet/General.cs +++ b/createsend-dotnet/General.cs @@ -3,6 +3,7 @@ using System.Text; using System.Web; using System.Collections.Specialized; +using Newtonsoft.Json; namespace createsend_dotnet { @@ -27,7 +28,8 @@ public static DateTime SystemDate() public static IEnumerable Countries() { - return XMLSerializer.Deserialize(HttpHelper.Get("/countries.xml", null)); + string json = HttpHelper.Get("/countries.json", null); + return (string[])JavaScriptConvert.DeserializeObject(json, typeof(string[])); } public static IEnumerable Timeszones() diff --git a/createsend-dotnet/createsend-dotnet.csproj b/createsend-dotnet/createsend-dotnet.csproj index 119e60d..645a10e 100755 --- a/createsend-dotnet/createsend-dotnet.csproj +++ b/createsend-dotnet/createsend-dotnet.csproj @@ -32,6 +32,10 @@ 4 + + False + lib\Newtonsoft.Json.dll + @@ -49,6 +53,10 @@ + + + +