private JToken FindParentNodeBySiblingValue(SiblingValueArguments args) { var collectionMatch = GetJToken( _Json, GetJsonQueryForNodes(args.PathArguments)); if (collectionMatch == null) { return(null); } var matches = collectionMatch.Children().ToList(); if (matches == null || matches.Count == 0) { return(null); } else { foreach (var item in matches) { if (item.HasValues == true) { if (item[args.SiblingSearchKey] != null && item[args.SiblingSearchKey].Value <string>() == args.SiblingSearchValue) { return(item); } } } return(null); } }
public void SetSiblingValue(SiblingValueArguments args) { var parentNode = FindParentNodeBySiblingValue(args); if (parentNode == null) { return; } else { parentNode[args.DesiredNodeKey] = args.DesiredNodeValue; } }
public string GetSiblingValue(SiblingValueArguments args) { var parentNode = FindParentNodeBySiblingValue(args); if (parentNode == null) { return(null); } else { var match = parentNode[args.DesiredNodeKey]; if (match == null) { return(null); } else { return(match.Value <string>()); } } }