U am facing a little Json conversion problem using Newtonsoft in Azure Functions.
I have an HttpTrigger
Function and am receiving a json string and convert it into my complex object afterwards.
My goal is to be able to convert my json string (below) to a c# Dictionary<AppLanguage, string>()
object.
I have the feeling it cannot read the integer in key and convert it to my enum value. So i guess there's a configuration for that?
System.Private.CoreLib: Exception while executing function: MyAppBranchFunctions. Newtonsoft.Json: Unexpected token StartArray when parsing enum. Path 'Texts.Tutorials', line 1, position 382828.
The json looks something like this:
{
"xxx":
{
"Texts":{"Tutorials":[{"Key":1,"Value":"tutorial"},{"Key":4,"Value":""},{"Key":5,"Value":""},{"Key":6,"Value":""},{"Key":7,"Value":""},{"Key":8,"Value":""},{"Key":9,"Value":""},{"Key":10,"Value":""},{"Key":2,"Value":""},{"Key":3,"Value":""}]
}
}
The signatures of the classes looks as follow:
public class Texts
{
[JsonConverter(typeof(StringEnumConverter))]
public Dictionary<AppLanguage, string> Tutorials { get; set; }
}
[JsonConverter(typeof(StringEnumConverter))]
public enum AppLanguage
{
/// <summary>
/// german
/// </summary>
[EnumMember(Value = "de")]
de,
/// <summary>
/// english
/// </summary>
[EnumMember(Value = "en")]
en,
/// <summary>
/// french
/// </summary>
[EnumMember(Value = "fr")]
fr,