When I try to serialize a simple List that stores EKEvent. I get this error:
Newtonsoft.Json.JsonSerializationException: Self referencing loop
detected for property 'Self' with type 'Foundation.NSDate'. Path
'[0].EndDate'.
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CheckForCircularReference
(Newtonsoft.Json.JsonWriter writer, System.Object value,
Newtonsoft.Json.Serialization.JsonProperty property,
Newtonsoft.Json.Serialization.JsonContract contract,
Newtonsoft.Json.Serialization.JsonContainerContract containerContract,
Newtonsoft.Json.Serialization.JsonProperty containerProperty)
[0x00105] in :0
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter. CalculatePropertyValues (Newtonsoft.Json.JsonWriter writer,
System.Object value,
Newtonsoft.Json.Serialization.JsonContainerContract contract,
Newtonsoft.Json.Serialization.JsonProperty member,
Newtonsoft.Json.Serialization.JsonProperty property,
Newtonsoft.Json.Serialization.JsonContract& memberContract,
System.Object& memberValue) [0x000c7] in :0
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject
(Newtonsoft.Json.JsonWriter writer, System.Object value,
Newtonsoft.Json.Serialization.JsonObjectContract contract,
Newtonsoft.Json.Serialization.JsonProperty member,
Newtonsoft.Json.Serialization.JsonContainerContract
collectionContract, Newtonsoft.Json.Serialization.JsonProperty
containerProperty) [0x0003c] in :0
This occurs when I try to use JsonConvert.SerializeObject method.
Any workaround for serializing an EKEvent list?
EDIT
Using JsonSerializerSettings works!
However, when I try to Deserialise the object, I get another problem:
Newtonsoft.Json.JsonSerializationException: Unable to find a constructor to use for type EventKit.EKEvent. #
A class should either have a default constructor,
one constructor with arguments or a constructor marked with the JsonConstructor attribute.
Path '[0].ClassHandle', line 1, position 16.
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateNewObject
(Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract objectContract,
Newtonsoft.Json.Serialization.JsonProperty containerMember,
Newtonsoft.Json.Serialization.JsonProperty containerProperty,
System.String id, System.Boolean& createdFromNonDefaultCreator) [0x000d6] in :0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.
CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x0013b] in :0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.
CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType
, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member,
Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x0006d] in :0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList (IList list,
Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonArrayContract contract,
Newtonsoft.Json.Serialization.JsonProperty containerProperty, System.String id) [0x000cb] in :0
Giorgi's answer answers the first part of your question on how to serialize your data, which you seem to have resolved. However, now you have an issue deserializing it again.
Looking at your stack trace that you have supplied in the opening post it says:
Unable to find a constructor to use for type EventKit.EKEvent. # A class should either have a default constructor, one constructor with arguments or a constructor marked with the JsonConstructor attribute
That says a lot about this error in particular. Now, looking at the EventKit EKEvent API reference, we find the following:
All the constructors are marked protected
There are no constructors that take no arguments
This means, when the DeserializeObject method tries to create an instance of EKEvent, it does not have any means to do so. It does not know what arguments to provide.
There are also other problems with the EKEvent class. Even if it had public constructors with no arguments. All the properties it has are marked read-only. This means when deserializing the serializer again, has no means of populating the properties with the serialized events.
So instead you have these two options:
Create a class wrapping EKEvent or imitating EKEvent and deserialize to that
Use the provided EKEventStore to persist EKEvents. As the API docs describe: "The EventStore is required to perform any operations in EventKit. It can be thought of as the persistent storage, or database, engine for all EventKit data."
The opening post does not describe the reasoning as to why you want to serialize and deserialize this object. However, if you want to communicate it to some API, I would suggest that you go for option 1. as it will not be platform specific and you can make it so that you only communicate relevant data between the App and API saving precious bandwidth.
You are getting the error because EKEvent has recursive references for it's properties. You can use ReferenceLoopHandling setting to specify that the json serializer should ignore self referencing loops:
JsonConvert.SerializeObject(myList, new JsonSerializerSettings
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
});
You can also set the serializer settings globally so that you don't have to specify it for every call:
JsonConvert.DefaultSettings = () => new JsonSerializerSettings
{
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
};
You can see full example at Json.NET documentation: http://www.newtonsoft.com/json/help/html/ReferenceLoopHandlingIgnore.htm
Related
I tried to found this answer a week. This look like easy to fix. but i got some image on docker that return this message error:
{
"ClassName": "Newtonsoft.Json.JsonSerializationException",
"Message": "Cannot deserialize the current JSON object (e.g. {\"name\":\"value\"}) into type 'System.Collections.Generic.IEnumerable`1[bank.Domain.Dto.DtoPriceCrypto]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.\nTo fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List<T>) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.\nPath 'code', line 2, position 9.",
"Data": null,
"InnerException": null,
"HelpURL": null,
"StackTraceString": " at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)\n at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)\n at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)\n at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)\n at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)\n at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)\n at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value)\n at bank.Domain.Nomics.GetInfoPriceCrypto(DtoGetInfoCrypto infoCrypto) in /app/Domain/Nomics.cs:line 49\n at bank.Domain.Wallet.SaldoWalletPessoa(Int32 crytoUserID) in /app/Domain/Wallet.cs:line 127\n at bank.Controllers.WalletController.SaldoWallet(DtoResquestWalletPessoa walletPessoa) in /app/Controllers/WalletController.cs:line 36",
"RemoteStackTraceString": null,
"RemoteStackIndex": 0,
"ExceptionMethod": null,
"HResult": -2146233088,
"Source": "Newtonsoft.Json",
"WatsonBuckets": null
}
when i try to use on my computer its works fine.
dockerfile
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS base
WORKDIR /app
COPY *.csproj ./
RUN dotnet restore
COPY . ./
RUN dotnet publish -c Release -o publish
FROM mcr.microsoft.com/dotnet/sdk:6.0
WORKDIR /app
COPY --from=base /app/publish .
ENTRYPOINT ["dotnet", "bank.dll", "/app/publish"]
CMD ASPNETCORE_URLS="http://*:$PORT" dotnet bank.dll
there is way to fix this into dockerfile ?
i tried to pull image docker on my pc and didnt get result. because its works in my localhost
I am developing a Web API, where the GET method needs to return an object, whose variables will be decided based on an XML file. The returned format must be either XML or JSON as requested by the client. I want to return the data inside XML file into XML format to the client, and something reasonable for JSON when JSON is requested.
The nodes in the XML might increase or decrease and therefore I cannot define a fixed class in the Models. My current solution is to return a dynamic object, but I am getting an exception shown below. What can I do to avoid the exception?
GET Api
[AllowAnonymous]
public class DataController : ApiController
{
//GET api/----based on dynamic binding
public object Get()
{
//Read XML
XDocument xDoc = XDocument.Load(#"D:\data.xml");
string jsonStr = JsonConvert.SerializeXNode(xDoc);
dynamic dynamicObject = JsonConvert.DeserializeObject<ExpandoObject>(jsonStr);
return dynamicObject; //THIS LINE IS THROWING RUNTIME ERROR
}
}
Sample XML File:
<Data>
<Name>abcd</Name>
<bad>100</bad>
<status>running</status>
</Data>
When I try to access the GET api, the following error appears on the web page:
<Error>
<Message>An error has occurred.</Message>
<ExceptionMessage>
The 'ObjectContent`1' type failed to serialize the response body for content type 'application/xml; charset=utf-8'.
</ExceptionMessage>
<ExceptionType>System.InvalidOperationException</ExceptionType>
<StackTrace/>
<InnerException>
<Message>An error has occurred.</Message>
<ExceptionMessage>
Type 'System.Dynamic.ExpandoObject' with data contract name 'ArrayOfKeyValueOfstringanyType:http://schemas.microsoft.com/2003/10/Serialization/Arrays' is not expected. Consider using a DataContractResolver if you are using DataContractSerializer or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to the serializer.
</ExceptionMessage>
<ExceptionType>
System.Runtime.Serialization.SerializationException
</ExceptionType>
<StackTrace>
at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeAndVerifyType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, Boolean verifyKnownType, RuntimeTypeHandle declaredTypeHandle, Type declaredType) at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithXsiTypeAtTopLevel(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle originalDeclaredTypeHandle, Type graphType) at System.Runtime.Serialization.DataContractSerializer.InternalWriteObjectContent(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver) at System.Runtime.Serialization.DataContractSerializer.InternalWriteObject(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver) at System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver) at System.Runtime.Serialization.DataContractSerializer.WriteObject(XmlWriter writer, Object graph) at System.Net.Http.Formatting.XmlMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, HttpContent content) at System.Net.Http.Formatting.XmlMediaTypeFormatter.WriteToStreamAsync(Type type, Object value, Stream writeStream, HttpContent content, TransportContext transportContext, CancellationToken cancellationToken) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.WebHost.HttpControllerHandler.<WriteBufferedResponseContentAsync>d__1b.MoveNext()
</StackTrace>
</InnerException>
</Error>
The reason you are getting that error is that you have declared your method to return an object of type object -- but have in fact returned a polymorphic subtype, namely ExpandoObject. Since DataContractSerializer (and XmlSerializer) will refuse to serialize unexpected polymorphic types, they throw the exception you are seeing. For details see
Understanding Known Types.
Data Contract Known Types.
Known Types.
That being said, I'd like to suggest a different, simpler approach. First, define your Get() method to explicitly return an XElement like so:
public XElement Get()
{
//Read XML
XDocument xDoc = XDocument.Load(#"D:\data.xml");
return xDoc.Root;
}
DataContractSerializer (and XmlSerializer) are both able to serialize an object of this type (since it implements IXmlSerializable), so your method will now successfully return contents of the file "D:\data.xml" verbatim when XML is requested.
Now, what to do when JSON is requested? As it turns out, Json.NET has a built-in converter XmlNodeConverter that can serialize an XElement to and from JSON. It's used internally by JsonConvert.SerializeXNode() but is public and so can be used directly. Thus if you add the converter to your global Web API list of converters in JsonSerializerSettings.Converters, your method should now return something reasonable for JSON as well.
You don't specify which version of Web API you are using. To add a converter globally, see
ASP.NET Web API 2: See How to set custom JsonSerializerSettings for Json.NET in MVC 4 Web API? and also the second part of this answer to Registering a custom JsonConverter globally in Json.Net. In this scenario your code would look something like:
protected void Application_Start()
{
var config = GlobalConfiguration.Configuration;
var settings = config.Formatters.JsonFormatter.SerializerSettings;
settings.Converters.Add(new XmlNodeConverter());
}
ASP.NET Core MVC: see JsonSerializerSettings and Asp.Net Core or Setting JsonConvert.DefaultSettings asp net core 2.0 not working as expected. Here again you would access the global JsonSerializerSettings and add an XmlNodeConverter as shown above.
I'm running a MVC project and utilizing Json, I have code that is running properly when running within Visual Studio, then I have a Site on IIS pointing to the same folder, when executed a URL from the IIS site my code doesn't perform the same as being in Visual Studio.
Within my code, I have:
return JsonConvert.SerializeObject(objectToSerialize);
When I send RouteData.Values, it produces this error:
Error getting value from 'CompiledAssembly' on 'System.CodeDom.Compiler.CompilerResults'.
at Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(JsonWriter writer, Object value, JsonContainerContract contract, JsonProperty member, JsonProperty property, JsonContract& memberContract, Object& memberValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeISerializable(JsonWriter writer, ISerializable value, JsonISerializableContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
at Newtonsoft.Json.JsonConvert.SerializeObjectInternal(Object value, Type type, JsonSerializer jsonSerializer)
at Newtonsoft.Json.JsonConvert.SerializeObject(Object value)
at x.Data.Helpers.Data.JsonHelper.SerializeObject(Object objectToSerialize) in D:\Development\x\x.Data\Helpers\Data\JsonHelper.cs:line 18
I am currently using Newtonsoft.Json, Version=11.0.0.0
Any ideas what is happening? Does IIS not have something that Visual Studio does?
I recently ran into this same exception with a different cause. Your RouteData.Values object is a RouteValueDictionary that can have objects as values, some of those objects may have Properties that throw an exception when the their 'get' is called.
You can handle these issues by passing in a JsonSerializerSettings object as the second parameter and override the Error EventHandler.
If you just want to ignore such properties, setting the ErrorEventArgs.ErrorContext.Handled to true should do the trick.
return JsonConvert.SerializeObject(objectToSerialize, new JsonSerializerSettings() { Error = new EventHandler<Newtonsoft.Json.Serialization.ErrorEventArgs>((obj, args) => {
args.ErrorContext.Handled = true;
}) });
This question already has answers here:
Failed to serialize the response in Web API with Json
(27 answers)
Closed 5 years ago.
I'm trying to create a WebApi to read a data from the DB using Entity Framework.
My data model design looks like this:
I have added a WebApi controller named SportsController like this:
public class SportsController : ApiController
{
public HttpResponseMessage Get()
{
try
{
using (MyLeagueDBEntities dbEntity = new MyLeagueDBEntities())
{
return Request.CreateResponse(HttpStatusCode.OK, dbEntity.tbl_Sports.ToList());
}
}
catch (Exception ex)
{
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex);
}
}
}
On invoking a request from browser to my WebApi controller GET method, I'm getting the exception shown below. But in debug mode, I can see that it is able to get the data from database without any error but once the control moves out of the method, it does throw the below exception.
Exception details:
"Message":"An error has occurred.",
"ExceptionMessage":"The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json; charset=utf-8'.",
"ExceptionType":"System.InvalidOperationException",
"StackTrace":null,
"InnerException":{"Message":"An error has occurred.",
"ExceptionMessage":"Error getting value from 'tbl_Tournament' on 'System.Data.Entity.DynamicProxies.tbl_Sports_7461105FEAC4FCCBDED534FCE44707AF9C7DFE1E4AD69B1E7E3777FBB953F184'.",
"ExceptionType":"Newtonsoft.Json.JsonSerializationException",
"StackTrace":"
at Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object target)\r\n
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(JsonWriter writer, Object value, JsonContainerContract contract, JsonProperty member, JsonProperty property, JsonContract& memberContract, Object& memberValue)\r\n
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)\r\n > at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)\r\n
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)\r\n
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)\r\n
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)\r\n
at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)\r\n
at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, Encoding effectiveEncoding)\r\n
at System.Net.Http.Formatting.JsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, Encoding effectiveEncoding)\r\n
at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, HttpContent content)\r\n
at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStreamAsync(Type type, Object value, Stream writeStream, HttpContent content, TransportContext transportContext, CancellationToken cancellationToken)\r\n
End of stack trace from previous location where exception was thrown
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n
at System.Web.Http.WebHost.HttpControllerHandler.d__1b.MoveNext()",
"InnerException":{"Message":"An error has occurred.",
"ExceptionMessage":"The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.",
"ExceptionType":"System.ObjectDisposedException",
"StackTrace":"
at System.Data.Entity.Core.Objects.ObjectContext.get_Connection()\r\n
at System.Data.Entity.Core.Objects.ObjectQuery1.GetResults(Nullable1 forMergeOption)\r\n
at System.Data.Entity.Core.Objects.ObjectQuery1.Execute(MergeOption
mergeOption)\r\n
at System.Data.Entity.Core.Objects.DataClasses.EntityCollection1.Load(List1
collection, MergeOption mergeOption)\r\n
at System.Data.Entity.Core.Objects.DataClasses.EntityCollection1.Load(MergeOption
mergeOption)\r\n
at System.Data.Entity.Core.Objects.DataClasses.RelatedEnd.DeferredLoad()\r\n
at System.Data.Entity.Core.Objects.Internal.LazyLoadBehavior.LoadProperty[TItem](TItem propertyValue, String relationshipName, String targetRoleName, Boolean mustBeNull, Object wrapperObject)\r\n
at System.Data.Entity.Core.Objects.Internal.LazyLoadBehavior.<>c__DisplayClass7`2.b__1(TProxy proxy, TItem item)\r\n
at System.Data.Entity.DynamicProxies.tbl_Sports_7461105FEAC4FCCBDED534FCE44707AF9C7DFE1E4AD69B1E7E3777FBB953F184.get_tbl_Tournament()\r\n
at Gettbl_Tournament(Object )\r\n
at Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object
target)"}}}
I'm new to Entity Framework and WebApi, requesting one to help me out resolving this issue.
PFB the snapshot with the error message logged on fiddler. Currently getting Http 500 internal server error,
It is because you have lazy loading enabled and you are serializing the object graph after you dispose of the DbContext instance. So what is happening
You create a DbContext
You retrieve the data from the DbContext for that one type
You pass the data to the Result method
Your DbContext is closed and disposed
Your method exists
Asp.Net mvc pipeline now tries to serialize the result's content
Relationships in your type are now attempted to be retrieved in the serialization process
The relationships are attempted to be retrieved from the DbContext because you have Lazy Loading enabled
The DbContext is disposed so access is not possible, an Exception is thrown
To fix it do one of the following
Move the DbContext to the class scope and dispose of it in the Disposing method (override the existing method from the ApiController)
(Recommended!) Turn off loazy loading and specify which properties you want to retrieve from the returned type using Include. This will enable more fine grained control over what is retrieved and is more performant because everything is retrieved in a single DB call instead of on access.
I want to deserialize some JSON inside a T4 template. I've referenced the assembly and all that and it all looks good but when I call this:
var root = JsonConvert.DeserializeObject<RootObject>(response);
I get this:
Error 4 Running transformation: System.TypeLoadException: Could not find Windows Runtime type 'Windows.Data.Json.IJsonValue'. ---> System.PlatformNotSupportedException: Operation is not supported on this platform.
--- End of inner exception stack trace ---
at Newtonsoft.Json.Converters.JsonValueConverter.CanConvert(Type objectType)
at Newtonsoft.Json.JsonSerializer.GetMatchingConverter(IList`1 converters, Type objectType)
at Newtonsoft.Json.Serialization.DefaultContractResolver.InitializeContract(JsonContract contract)
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract(Type objectType)
at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract(Type objectType)
at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract(Type type)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value)
at Microsoft.VisualStudio.TextTemplating051377DF83FAD6CEB531E8C53BDF7AF0925D52AE4E0D72D32E8A27AD05041FA9D55204F2BCFCC44A6977B1EA4AD1DA5E9682BFE9EB924836019C6E14E1AED232.GeneratedTextTransformation.GetInfoForCountries() in c:\************\CalabashTestGeneration\Template1.tt:line 117
at Microsoft.VisualStudio.TextTemplating051377DF83FAD6CEB531E8C53BDF7AF0925D52AE4E0D72D32E8A27AD05041FA9D55204F2BCFCC44A6977B1EA4AD1DA5E9682BFE9EB924836019C6E14E1AED232.GeneratedTextTransformation.TransformText() in c:\****************\CalabashTestGeneration\Template1.tt:line 24 c:\*************\CalabashTestGeneration\Template1.tt 117 1 CalabashTestGeneration
Is this even possible? I don't see why a T4 couldn't use newtonsoft but this kind of hints that it can't!
I've ended up using restsharp - seems to work so far