Reputation:
I want to develop a simple library that uses a web service. The web service serves requests with JSON responses, so this library will require a JSON serialization and deserialization library (probably the JavaScriptSerializer API's in Microsoft's System.Web assembly.
I also want to build a Windows Phone 8 library that will use the previously mentioned library. However, it looks like it is not that simple. Windows Phone 8 can only reference some special type of assembly (Microsoft calls it portable libraries). If I make it a portable library, then I can no longer use Microsoft' System.Web assembly to work with JSON objects.
So in summary, is there a way for me to create a plain old C# library with dependencies to some sort of JSON library that will work with any project written in C# (Windows Phone, WCF, MVC, and so on)?
Upvotes: 0
Views: 109
Reputation: 2331
Just to clarify: Windows Phone 8 does not require Portable Class Libraries - you can build a class library that targets the Windows Phone platform directly. Portable Class Libraries are useful when you want to build a library that targets multiple platforms, for example:
The second of the links provided by @SLaks points to the Json.NET library which is now available as a Portable Class Library - most conveniently as a Nuget package in the latest build: http://james.newtonking.com/archive/2012/10/07/json-net-4-5-release-10-portable-class-library-on-nuget.aspx.
If you build your own Portable Class Library, you can reference the Json.NET Portable Class Library to enable Json Serialization and Deserialization.
Upvotes: 0