📅  最后修改于: 2022-03-11 14:49:06.856000             🧑  作者: Mango
// Construct a JObject.
var jObject = JObject.Parse("{ SomeName: \"Some value\" }");
// Deserialize the object into an ExpandoObject (don't use object, because you will get a JObject).
var payload = JsonConvert.DeserializeObject(jObject.ToString());
// Now you can serialize the object using any serializer settings you like.
var json = JsonConvert.SerializeObject(payload, new JsonSerializerSettings
{
ContractResolver = new DefaultContractResolver
{
NamingStrategy = new CamelCaseNamingStrategy
{
// Important! Make sure to set this to true, since an ExpandoObject is like a dictionary.
ProcessDictionaryKeys = true,
}
}
}
);
Console.WriteLine(json); // Outputs: {"someName":"Some value"}