Beispiel #1
0
            public Interpreter(JsonPathResultAccumulator output, IJsonPathValueSystem valueSystem, JsonPathScriptEvaluator eval)
            {
                Debug.Assert(output != null);

                _output = output;
                _eval   = eval ?? NullEval;
                _system = valueSystem ?? DefaultValueSystem;
            }
Beispiel #2
0
            public Interpreter(JsonPathResultAccumulator output, IJsonPathValueSystem valueSystem, JsonPathScriptEvaluator eval)
            {
                Debug.Assert(output != null);

                this.output = output;
                this.eval   = eval != null ? eval : new JsonPathScriptEvaluator(NullEval);
                this.system = valueSystem != null ? valueSystem : defaultValueSystem;
            }
Beispiel #3
0
 public Interpreter(IJsonPathValueSystem valueSystem, Func <string, object, string, object> eval)
 {
     if (eval == null)
     {
         this.eval = (a, b, c) => null;
     }
     else
     {
         this.eval = eval;
     }
     this.system = valueSystem ?? DefaultValueSystem;
 }
Beispiel #4
0
            public Interpreter(IJsonPathValueSystem valueSystem, Func <string, object, string, object> eval)
            {
                _eval = eval ?? delegate
                {
                    // @ symbol in expr must be interpreted specially to resolve
                    // to value. In JavaScript, the implementation would look
                    // like:
                    //
                    // return obj && value && eval(expr.replace(/@/g, "value"));

                    return(null);
                };
                _system = valueSystem ?? DefaultValueSystem;
            }
        public IEnumerable<JsonPathExpression> ParseExpression(JsonPathModel model, ScriptEvaluatorFactory.ScriptEvaluatorTypes evaluatorType = ScriptEvaluatorFactory.ScriptEvaluatorTypes.Basic, IJsonPathValueSystem valueSystem = null)
        {
            IList<JsonPathExpression> result = new List<JsonPathExpression>(model.Expressions.Count());
            var json = JsonConvert.DeserializeObject(model.SourceJson);

            var context = new JsonPathContext
            {
                ScriptEvaluator = new JsonPathScriptEvaluator(ScriptEvaluatorFactory.Create(evaluatorType).EvaluateScript),
                ValueSystem = valueSystem
            };

            foreach(JsonPathExpression expression in model.Expressions)
            {
                var nodes = context.SelectNodes(json, expression.Expression);
                Array.Copy(nodes, expression.Nodes.ToArray(), nodes.Length);
                result.Add(expression);
            }

            return result.AsEnumerable();
        }
Beispiel #6
0
        public IEnumerable <JsonPathExpression> ParseExpression(JsonPathModel model, ScriptEvaluatorFactory.ScriptEvaluatorTypes evaluatorType = ScriptEvaluatorFactory.ScriptEvaluatorTypes.Basic, IJsonPathValueSystem valueSystem = null)
        {
            IList <JsonPathExpression> result = new List <JsonPathExpression>(model.Expressions.Count());
            var json = JsonConvert.DeserializeObject(model.SourceJson);

            var context = new JsonPathContext
            {
                ScriptEvaluator = new JsonPathScriptEvaluator(ScriptEvaluatorFactory.Create(evaluatorType).EvaluateScript),
                ValueSystem     = valueSystem
            };

            foreach (JsonPathExpression expression in model.Expressions)
            {
                var nodes = context.SelectNodes(json, expression.Expression);
                Array.Copy(nodes, expression.Nodes.ToArray(), nodes.Length);
                result.Add(expression);
            }

            return(result.AsEnumerable());
        }
            public Interpreter(JsonPathResultAccumulator output, IJsonPathValueSystem valueSystem,
                JsonPathScriptEvaluator eval)
            {
                Debug.Assert(output != null);

                _output = output;
                _eval = eval ?? NullEval;
                _system = valueSystem ?? DefaultValueSystem;
            }
Beispiel #8
-1
            public Interpreter(JsonPathResultAccumulator output, IJsonPathValueSystem valueSystem, JsonPathScriptEvaluator eval)
            {
                Debug.Assert(output != null);

                this.output = output;
                this.eval = eval != null ? eval : new JsonPathScriptEvaluator(NullEval);
                this.system = valueSystem != null ? valueSystem : defaultValueSystem;
            }