Skip to content

Commit

Permalink
103 prerelease stuff
Browse files Browse the repository at this point in the history
swapped jsonserialier and misc packaging
  • Loading branch information
johnsheehan committed Apr 10, 2012
1 parent 2f73bd3 commit 9d11af9
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 53 deletions.
3 changes: 3 additions & 0 deletions RestSharp.Silverlight/RestSharp.Silverlight.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@
<Compile Include="..\RestSharp\Serializers\ISerializer.cs">
<Link>Serializers\ISerializer.cs</Link>
</Compile>
<Compile Include="..\RestSharp\Serializers\JsonSerializer.cs">
<Link>Serializers\JsonSerializer.cs</Link>
</Compile>
<Compile Include="..\RestSharp\Serializers\SerializeAsAttribute.cs">
<Link>Serializers\SerializeAsAttribute.cs</Link>
</Compile>
Expand Down
3 changes: 3 additions & 0 deletions RestSharp.WindowsPhone/RestSharp.WindowsPhone.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@
<Compile Include="..\restsharp\serializers\ISerializer.cs">
<Link>Serializers\ISerializer.cs</Link>
</Compile>
<Compile Include="..\RestSharp\Serializers\JsonSerializer.cs">
<Link>Serializers\JsonSerializer.cs</Link>
</Compile>
<Compile Include="..\restsharp\serializers\SerializeAsAttribute.cs">
<Link>Serializers\SerializeAsAttribute.cs</Link>
</Compile>
Expand Down
2 changes: 1 addition & 1 deletion RestSharp/RestRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public RestRequest()
Parameters = new List<Parameter>();
Files = new List<FileParameter>();
XmlSerializer = new XmlSerializer();
//JsonSerializer = new JsonSerializer();
JsonSerializer = new JsonSerializer();

OnBeforeDeserialization = r => { };
}
Expand Down
1 change: 1 addition & 0 deletions RestSharp/RestSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
<Compile Include="Deserializers\DotNetXmlDeserializer.cs" />
<Compile Include="Serializers\DotNetXmlSerializer.cs" />
<Compile Include="Serializers\ISerializer.cs" />
<Compile Include="Serializers\JsonSerializer.cs" />
<Compile Include="Serializers\SerializeAsAttribute.cs" />
<Compile Include="Serializers\XmlSerializer.cs" />
<Compile Include="Http.Async.cs" />
Expand Down
57 changes: 7 additions & 50 deletions RestSharp/Serializers/JsonSerializer.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,4 @@
#region License
// Copyright 2010 John Sheehan
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#endregion
#region Acknowledgements
// Original JsonSerializer contributed by Daniel Crenna (@dimebrain)
#endregion

using System.IO;
using Newtonsoft.Json;
using System.IO;

namespace RestSharp.Serializers
{
Expand All @@ -28,45 +8,22 @@ namespace RestSharp.Serializers
/// </summary>
public class JsonSerializer : ISerializer
{
private readonly Newtonsoft.Json.JsonSerializer _serializer;

/// <summary>
/// <summary>
/// Default serializer
/// </summary>
public JsonSerializer() {
public JsonSerializer()
{
ContentType = "application/json";
_serializer = new Newtonsoft.Json.JsonSerializer {
MissingMemberHandling = MissingMemberHandling.Ignore,
NullValueHandling = NullValueHandling.Include,
DefaultValueHandling = DefaultValueHandling.Include
};
}

/// <summary>
/// Default serializer with overload for allowing custom Json.NET settings
/// </summary>
public JsonSerializer(Newtonsoft.Json.JsonSerializer serializer){
ContentType = "application/json";
_serializer = serializer;
}

/// <summary>
/// Serialize the object as JSON
/// </summary>
/// <param name="obj">Object to serialize</param>
/// <returns>JSON as String</returns>
public string Serialize(object obj) {
using (var stringWriter = new StringWriter()) {
using (var jsonTextWriter = new JsonTextWriter(stringWriter)) {
jsonTextWriter.Formatting = Formatting.Indented;
jsonTextWriter.QuoteChar = '"';

_serializer.Serialize(jsonTextWriter, obj);

var result = stringWriter.ToString();
return result;
}
}
public string Serialize(object obj)
{
return SimpleJson.SerializeObject(obj);
}

/// <summary>
Expand Down
Binary file modified Tools/NuGet.exe
Binary file not shown.
5 changes: 4 additions & 1 deletion package.cmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if not exist Download\Silverlight mkdir Download\Silverlight
if not exist Download\Silverlight mkdir Download\Silverlight
if not exist Download\WindowsPhone\7.0\ mkdir Download\WindowsPhone\7.0\
if not exist Download\WindowsPhone\7.1\ mkdir Download\WindowsPhone\7.1\
if not exist Download\package\lib\net35 mkdir Download\package\lib\net35
Expand All @@ -19,6 +19,8 @@ copy RestSharp.WindowsPhone.Mango\bin\Release\*.dll Download\WindowsPhone\7.1\
copy RestSharp.WindowsPhone.Mango\bin\Release\*.xml Download\WindowsPhone\7.1\

copy LICENSE.txt Download
copy readme.txt Download
copy readme.txt Download\package

copy RestSharp\bin\Release\RestSharp.dll Download\Package\lib\net35\
copy RestSharp\bin\Release\RestSharp.dll Download\Package\lib\net35-client\
Expand All @@ -32,4 +34,5 @@ copy RestSharp.Silverlight\bin\Release\RestSharp.Silverlight.xml Download\Packag
copy RestSharp.WindowsPhone\bin\Release\RestSharp.WindowsPhone.xml Download\Package\lib\sl3-wp\
copy RestSharp.WindowsPhone.Mango\bin\Release\RestSharp.WindowsPhone.xml Download\Package\lib\sl4-wp71\

tools\nuget.exe update -self
tools\nuget.exe pack restsharp.nuspec -BasePath Download\Package -Output Download
12 changes: 12 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*** IMPORTANT CHANGE IN VERSION 103 ***

In 103.0, JSON.NET was removed as a dependency.

If this is still installed in your project and no other libraries depend on it you may remove it from your installed packages.

There is one breaking change: the default JsonSerializer is no longer compatible with Json.NET. To use Json.NET for serialization, copy the code from https://github.com/restsharp/RestSharp/blob/86b31f9adf049d7fb821de8279154f41a17b36f7/RestSharp/Serializers/JsonSerializer.cs and register it with your client:

var client = new RestClient();
client.JsonSerializer = new YourCustomSerializer();

If you run into any compatibility issues with deserialization, please report it to http://groups.google.com/group/restsharp
4 changes: 3 additions & 1 deletion restsharp.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package>
<metadata>
<id>RestSharp</id>
<version>102.7</version>
<version>103.0.0-nojsondotnet</version>
<authors>John Sheehan, RestSharp Community</authors>
<owners>John Sheehan</owners>
<description>Simple REST and HTTP API Client</description>
Expand All @@ -12,6 +12,8 @@
<iconUrl>http://dl.dropbox.com/u/1827/restsharp100.png</iconUrl>
<tags>REST HTTP API JSON XML</tags>
<releaseNotes>
103.0 - Remove dependency on Json.NET
Remove WP7.0 support (7.1 Mango remains).
102.7 - Updating Json.NET to 4.0.8, misc fixes
102.6 - Updating Json.NET reference to 4.0.5
</releaseNotes>
Expand Down

0 comments on commit 9d11af9

Please sign in to comment.