에서 나는 다음과 같은 특성을했습니다이름 바꾸기 JProperty이 json.net
{
"bad":
{
"Login": "someLogin",
"Street": "someStreet",
"House": "1",
"Flat": "0",
"LastIndication":
[
"230",
"236"
],
"CurrentIndication":
[
"263",
"273"
],
"Photo":
[
null,
null
]
}
}
내가 예를 들어 '좋은'로 '나쁜'에서이 이름을 변경하는 방법에 대해 설명합니다. 네, 아비 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);
}
}
하여 확장 메서드를 보았다하지만 Newtonsoft.Json.Linq.JProperty 에 Newtonsoft.Json.Linq.JProperty를 추가 할 수 없습니다이 exeption에게
을 얻었다.
가능한 중복 Json의 부동산 정보] (https://stackoverflow.com/questions/40002773/changing-key-of-an-property-in-json) –
시원하게 보이지만 작동하지 않습니다. 이 예에서는, JObject의 루트 obj를 작성합니다. 하지만 제 경우에는 JProperty 배열을 가지고 있고 foreach에서 이것을 사용합니다. 'JArray curLog = JArray.Parse (currentJsonLog); curLog.Children() .ToList() .ForEach (O => o.Properties(). ToList() .ForEach (p => { 경우 (p.Name ==) "나쁜" {/ /p.ChangeKey("새 이름");}' –
NisuSan