G
G
getfield2021-06-30 17:18:43
C++ / C#
getfield, 2021-06-30 17:18:43

How to deserialize empty Guid array using Newtonsoft deserializer?

I get data from the API and try to deserialize it into a list of objects, but the deserialization fails. ErrorMessage: No parameterless constructor defined for type 'System.Guid[]'. How can I fix this MissingMethodException? Where can I add this empty constructor?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2021-06-30
@vabka

What version of Newtonsoft are you using?
On .NET 5 and Newtonsoft.Json/13.0.1 everything is ok.

#r "nuget:Newtonsoft.Json/13.0.1"
var guids = Newtonsoft.Json.JsonConvert.DeserializeObject<Guid[]>("[]").Dump();
var guids2 = System.Text.Json.JsonSerializer.Deserialize<Guid[]>("[]").Dump();

+ Why use newtonsoft when you have STJ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question