资源简介

json.dll及源码。发现Newtonsoft.json不能用在WINCE,至少不能所有WINCE版本都实用;但json.dll却可以轻松的实现WinCe下的JSON(反)序列化;网上有很多地方可以下载到json.dll,但我这个版本是json.dll的源代码,因为json.dll没有文档,有源码各位满意了吧^_^

资源截图

代码片段和文件信息

using System;
using System.Globalization;
using System.IO;
namespace Json
{
public class Converter
{
public static void Serialize(Stream output object instance)
{
Converter.Serialize(output instance string.Empty);
}
public static void Serialize(Stream output object instance string fieldPrefix)
{
JsonWriter jsonWriter = new JsonWriter(output);
JsonSerializer.Serialize(jsonWriter instance fieldPrefix);
jsonWriter.Flush();
}
public static void Serialize(string file object instance)
{
Converter.Serialize(file instance string.Empty);
}
public static void Serialize(string file object instance string fieldPrefix)
{
using (JsonWriter jsonWriter = new JsonWriter(file))
{
JsonSerializer.Serialize(jsonWriter instance fieldPrefix);
}
}
public static string Serialize(object instance)
{
return Converter.Serialize(instance string.Empty);
}
public static string Serialize(object instance string fieldPrefix)
{
string result;
using (StringWriter stringWriter = new StringWriter(CultureInfo.get_InvariantCulture()))
{
using (JsonWriter jsonWriter = new JsonWriter(stringWriter))
{
JsonSerializer.Serialize(jsonWriter instance fieldPrefix);
result = stringWriter.ToString();
}
}
return result;
}
public static void Serialize(Stream output object instance PreFieldSerializingDelegate callback)
{
Converter.Serialize(output instance string.Empty);
}
public static void Serialize(Stream output object instance string fieldPrefix PreFieldSerializingDelegate callback)
{
JsonWriter jsonWriter = new JsonWriter(output);
JsonSerializer.Serialize(jsonWriter instance fieldPrefix callback);
jsonWriter.Flush();
}
public static void Serialize(string file object instance PreFieldSerializingDelegate callback)
{
Converter.Serialize(file instance string.Empty callback);
}
public static void Serialize(string file object instance string fieldPrefix PreFieldSerializingDelegate callback)
{
using (JsonWriter jsonWriter = new JsonWriter(file))
{
JsonSerializer.Serialize(jsonWriter instance fieldPrefix callback);
}
}
public static string Serialize(object instance PreFieldSerializingDelegate callback)
{
return Converter.Serialize(instance string.Empty callback);
}
public static string Serialize(object instance string fieldPrefix PreFieldSerializingDelegate callback)
{
string result;
using (StringWriter stringWriter = new StringWriter(CultureInfo.get_InvariantCulture()))
{
using (JsonWriter jsonWriter = new JsonWriter(stringWriter))
{
JsonSerializer.Serialize(jsonWriter instance fieldPrefix callback);
result = stringWriter.ToString();
}
}
return result;
}
public static T Deserialize(Stream input)
{
return Converter.Deserialize(input string.Empty);
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2015-01-29 12:45  Jons\
     目录           0  2015-01-29 12:42  Jons\Json\
     文件        1959  2015-01-29 12:42  Jons\Json.csproj
     文件       23040  2015-01-29 12:37  Jons\Json.dll
     目录           0  2015-01-29 12:42  Jons\Json.Helpers\
     文件         400  2015-01-29 12:42  Jons\Json.Helpers\DateHelper.cs
     文件         925  2015-01-29 12:42  Jons\Json.Helpers\DictHelper.cs
     文件        2085  2015-01-29 12:42  Jons\Json.Helpers\ListHelper.cs
     文件        1817  2015-01-29 12:42  Jons\Json.Helpers\Reflectionhelper.cs
     文件        4097  2015-01-29 12:42  Jons\Json\Converter.cs
     文件        8465  2015-01-29 12:42  Jons\Json\JsonDeserializer.cs
     文件         296  2015-01-29 12:42  Jons\Json\JsonException.cs
     文件        1693  2015-01-29 12:42  Jons\Json\Jsonhelper.cs
     文件        8035  2015-01-29 12:42  Jons\Json\JsonReader.cs
     文件        5664  2015-01-29 12:42  Jons\Json\JsonSerializer.cs
     文件         415  2015-01-29 12:42  Jons\Json\JsonTokens.cs
     文件        2665  2015-01-29 12:42  Jons\Json\JsonWriter.cs
     文件         120  2015-01-29 12:42  Jons\Json\PreFieldSerializingDelegate.cs

评论

共有 条评论