So I'm going to jump straight in.
I'm using Windows.Data.Json to convert and use some JSON from a web service. I know about Newtonsoft.Json.Net, and some of the others etc. and yes, I am specifically trying to use Windows.Data.Json, for company and dependency reasons.
The application has 3 main parts/components.
- A UWP Win 10 app - the main app
- An MVC Web Project - web services for the app
- A Portable Class Library - for shared classes between both
The problem I have is that when I use JsonObject in either the MVC web project or the PCL, I am getting the error:
The type 'IStringable' is defined in an assembly that is not referenced. You must add a reference to assembly 'Windows.Foundation.FoundationContract, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null, ContentType=WindowsRuntime'.
This error is showing up everywhere I use the JsonObject, however, NOT in the UWP app project.
e.g.
//Convert string to json object
var apiJsonObj = JsonObject.Parse(jsonString);
and
cc.Type = apiJsonObj["TYPE"].ToString();
I've searched online, and cannot find anything useful about Windows.Data.Json, nor the IStringable, other than this:
https://docs.microsoft.com/en-us/uwp/api/windows.foundation.istringable
My project does not have Windows.Foundation.FoundationContract listed in the Add References dialogue, and I cannot find any references to it in the UWP app that I am using, nor any other information that has been of use.
The UWP app and the MVC Web app use literally the same lines of code to interpret the JsonObject. The UWP app works. The MVC Web app gives the above error.
I was wondering if anyone else has been using Windows.Data.Json successfully, and may have come across this issue, and a fix?
The applications must be as small and independent as possible, hence the small number of references, and not being able to use Json.Net etc.