[Question] Ignore property casing using JSON
MarkNL2 opened this issue · 1 comments
MarkNL2 commented
I am trying to make Handlebars to parse my templates with case-insensitive properties.
By default this works fine when using dynamics:
var data = new{
name = "firstname",
Lastname = "LastName"
};
Handlebars.Compile("Name: {{Name}} {{LastName}}").Invoke(data)
Result : Name: firstname LastName
But when I use Json as input data the properties seem to be case sensitive:
var data = JsonConvert.DeserializeObject<ExpandoObject>("{name:\"firstname\",Lastname:\"LastName\"}");
Handlebars.Compile("Name: {{Name}} {{LastName}}").Invoke(data);
Result:Name:
I have also tested it with:
- JsonConvert.DeserializeObject< ExpandoObject>()
- JsonConvert.DeserializeObject< dynamic>
How can i get get the same results as C# dynamics with JSON data?
Update note: fixed code blocks
oformaniuk commented
Hello @Markkl
You can find explanation for such a behavior (and a potential fix) in the following issue: #362
You may also use JObject
directly in combination with Handlebars.Net.Extension.NewtonsoftJson