Skip to content

Commit

Permalink
Demonstration of how json serialisation works nicely using the Newton…
Browse files Browse the repository at this point in the history
…soft.Json library for .NET 2.0.
  • Loading branch information
jdennes committed Nov 10, 2010
1 parent 31b2a1e commit b8c178c
Show file tree
Hide file tree
Showing 5 changed files with 1,002 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ConsoleRunner/Program.cs
Expand Up @@ -11,7 +11,7 @@ static void Main(string[] args)
{
foreach(string country in General.Countries())
Console.WriteLine(country);

Console.ReadLine();
}
}
}
4 changes: 3 additions & 1 deletion createsend-dotnet/General.cs
Expand Up @@ -3,6 +3,7 @@
using System.Text;
using System.Web;
using System.Collections.Specialized;
using Newtonsoft.Json;

namespace createsend_dotnet
{
Expand All @@ -27,7 +28,8 @@ public static DateTime SystemDate()

public static IEnumerable<string> Countries()
{
return XMLSerializer.Deserialize<Countries>(HttpHelper.Get("/countries.xml", null));
string json = HttpHelper.Get("/countries.json", null);
return (string[])JavaScriptConvert.DeserializeObject(json, typeof(string[]));
}

public static IEnumerable<string> Timeszones()
Expand Down
8 changes: 8 additions & 0 deletions createsend-dotnet/createsend-dotnet.csproj
Expand Up @@ -32,6 +32,10 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=1.3.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>lib\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Data" />
Expand All @@ -49,6 +53,10 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Models\Result.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="lib\Newtonsoft.Json.dll" />
<Content Include="lib\Newtonsoft.Json.XML" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down

0 comments on commit b8c178c

Please sign in to comment.