我有以下财产
{
"bad":
{
"Login": "someLogin",
"Street": "someStreet",
"House": "1",
"Flat": "0",
"LastIndication":
[
"230",
"236"
],
"CurrentIndication":
[
"263",
"273"
],
"Photo":
[
null,
null
]
}
}
Run Code Online (Sandbox Code Playgroud)
以及如何将其从“坏”重命名为“好”。是的,我看到了Abi Bellamkonda的扩展方法
public static class NewtonsoftExtensions
{
public static void Rename(this JToken token, string newName)
{
var parent = token.Parent;
if (parent == null)
throw new InvalidOperationException("The parent is missing.");
var newToken = new JProperty(newName, token);
parent.Replace(newToken);
}
}
Run Code Online (Sandbox Code Playgroud)
但是它得到了这个证明
无法将Newtonsoft.Json.Linq.JProperty添加到Newtonsoft.Json.Linq.JProperty。