public JsonPathNode[] SelectNodes(object obj, string expr) { var list = new ArrayList(); SelectNodesTo(obj, expr, list); return (JsonPathNode[]) list.ToArray(typeof (JsonPathNode)); }
public void ApplyPath() { if(String.IsNullOrEmpty(RequestResponse) || String.IsNullOrEmpty(JsonPath)) { return; } JsonPath = JsonPath.Trim(); try { var json = JObject.Parse(RequestResponse); var context = new JsonPathContext { ValueSystem = new JsonNetValueSystem() }; var values = context.SelectNodes(json, JsonPath).Select(node => node.Value); var newResponseValue = JsonConvert.SerializeObject(values); JsonPathResult = newResponseValue; } catch(JsonException je) { Dev2Logger.Log.Error(je); } }