示例#1
0
        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.Error(je, GlobalConstants.WarewolfError);
            }
        }