如何在使用JsonWriter时保留原始JSON大小写?

时间:2017-03-24 09:27:46

标签: c# json json.net .net-core

如何保持原装? (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
   }
}

0 个答案:

没有答案