如何保持原装? (JsonWriter WriteTo总是转换为骆驼套管)
示例JSON
class Animal
{
[SearchableProperty]
public string Type { get; set;}
public string ImNotSearchable { get; set;}
}
class Fish : Animal { }
class Dog : Animal
{
[SearchableProperty]
public string Color { get; set;}
}
[AttributeUsage(AttributeTargets.Property, Inherited = false)]
class SearchablePropertyAttribute : Attribute
{
}
animals.FindAll(animal => animal.GetType().GetProperties().Where(
prop => Attribute.IsDefined(prop, typeof(SearchablePropertyAttribute))).Any(p => p.GetValue(animal)?.ToString()?.Contains(keyword) ?? false))
我的方法
{
"order":"123",
"item_xyz":{
"some_property":"some value",
"another_property":null,
"yet_another_property":123
}
}