简体   繁体   English

NET CompactFramework 2.0的JSON序列化器

[英]JSON serializer for .NET CompactFramework 2.0

I need to Serialize and De-serialize Custom Objects under .NET Compact Framework 2.0. 我需要在.NET Compact Framework 2.0下对自定义对象进行序列化和反序列化。 I have gone through JSON.NET 3.5 but it need .NET Compact Framework 3.5. 我已经通过JSON.NET 3.5,但是它需要.NET Compact Framework 3.5。

I am restricted to not to upgrade from 2.0 to 3.5. 我被限制为不从2.0升级到3.5。 When I am trying with version JSON.Net 2.0, Serialize and Deserialize operations are hanging up. 当我尝试使用JSON.Net 2.0版本时,序列化和反序列化操作正在挂起。

---Serialize-----
List<string> strMessage = (JavaScriptConvert.DeserializeObject(results, typeof(List<string>)) as List<string>);
-----Deserialize----
 List<object> paramObject = new List<object>(paramCollection);
            string postData = string.Empty;

            if (paramObject.Count > 0)
            {
                postData = JavaScriptConvert.SerializeObject(paramObject);
            }

Note: paramCollection is the Array of objects ( object[] ) 注意:paramCollection是对象的数组(object [])

Is there something wrong in the above code? 上面的代码有问题吗? The same I tested with Desktop and I found it working but not in Compact Framework. 我在Desktop上进行了测试,发现它可以正常工作,但在Compact Framework中却不能。

about a year ago I faced the same sort of issue. 大约一年前,我面临同样的问题。 JSON, compact framework, .net 2 JSON,紧凑型框架,.net 2

I ended up using http://jsoncf.codeplex.com/ 我最终使用了http://jsoncf.codeplex.com/

The source page I found on codebetter.com does contain this disclaimer: 我在codebetter.com上找到的源页面确实包含以下免责声明:

Use it at your own risk - it’s very early in in development and poorly tested. 

On the whole I found it works; 总的来说,我发现它有效。 From memory it does not deal with nulls nicely, and I think I had to tweak datetime serialisation to make it work the way other json serialisers do. 从内存来看,它不能很好地处理空值,我想我必须调整datetime序列化以使其像其他json序列化程序那样工作。

If you're interested in pursuing this I can go and find the amendments I needed to make and post them. 如果您有兴趣进行此操作,我可以去找我需要进行修改并发布的修改。

Andrew 安德鲁

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM