I have a class like:
[JsonObject(MemberSerialization.OptIn)] public class foo { [JsonProperty("name_in_json")] public string Bar { get; set; }
JSON is generated from the CSV file initially, each line represents a foo object - it is mostly flat, so I need to map specific keys to image flags.
I tried to write CustomCreationConverter using an example here .
It looks like the flags are fine, but the usual properties cannot be set - it searches for "bar" instead of "name_in_json".
How do I get the value 'name_in_json' for an object of type foo?
edit:
current solution:
var custAttrs = objectType.GetProperties().Select(p => p.GetCustomAttributes(typeof(JsonPropertyAttribute), true)).ToArray(); var propNames = objectType.GetProperties().Select(p => p.Name.ToLower()).ToArray(); Dictionary<string, string> objProps = new Dictionary<string, string>(); for (int i = 0; i < propNames.Length; i++)
source share