Corneloues
Corneloues

Reputation: 87

Json.Net and Metro/Store Apps

Been racking my brain, but have managed to work out that the current build of Json.Net won't work with Metro/Store apps.

I included a reference to the Net40 version of the library, but I kept getting compilation errors stating that the reference could not be added as

"The project targets '.NetCore' while the file references targets '.NetFramework'. This is not a supported scenario."

So I tried creating a standard forms based VB.net app in VS2012 and low and behold Json.Net imported perfectly.

The issue appears to centre around System.ComponentModel.PropertyDescriptor which does not appear to be available in .Netcore.

Update:

I tried adding the Portable version of Json.net and got the following error when tring to build the app:

CA0001 Error Running Code Analysis CA0001 : Rule=Microsoft.Reliability#CA2002, Target=Jobs.Store.MainPage.#JobView_Respond(Jobs.Store.WebViewResponse) : The following error was encountered while reading module 'Jobs.Store': Could not resolve member reference: [Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed]Newtonsoft.Json.JsonConvert::SerializeObject. [Errors and Warnings] (Global)

I'm hoping James Newton-King picks this up as he appears to be quite active here ;-)

Other than that I'm finding it very difficult to serailize JSON in Metro apps!

Cheers,

Roy

Upvotes: 1

Views: 557

Answers (1)

fundead
fundead

Reputation: 1329

Just had the same problem, and it's resolved by grabbing the actual WinRT build of the library. It doesn't seem to be mentioned anywhere on the web, but if you grab the latest build (at time of writing) here:

http://json.codeplex.com/releases/view/97986

inside /Bin, you'll find the WinRT folder - reference the DLL inside there and you should be up and running.

Edit: JSON.NET does a fairly decent job, but we're developing a library and decided we didn't want to add a dependency. Also, in the past it's had version conflict issues - so we switched to SimpleJson (not SimpleJson.net from github, note!). This is only one class and is pretty awesome at serializing if that's what you need. It's available from NuGet with

Install-Package SimpleJson

Upvotes: 2

Related Questions