Example #1
0
        public IEnumerable <Json> Mash(Json json, IMashContext context)
        {
            context = context.PushStack(this);
            context.Tick();
            var result = new List <Json>();

            try
            {
                foreach (var value in TryBody.Mash(json, context))
                {
                    result.Add(value);
                }
            }
            catch (JsonMasherException ex)
            {
                if (CatchBody != null)
                {
                    foreach (var value in CatchBody.Mash(Json.String(ex.Message), context))
                    {
                        result.Add(value);
                    }
                }
            }
            return(result);
        }
Example #2
0
        public IEnumerable <Json> Mash(Json json, IMashContext context)
        {
            context = context.PushStack(this);
            context.Tick();
            var result = Descriptor switch {
                FunctionName name => CallFunctionName(name, json, context),
                Builtin builtin => RunBuiltin(builtin, json, context),
                _ => throw new InvalidOperationException()
            };

            return(result);
        }
Example #3
0
 public static IEnumerable <PathAndValue> GeneratePaths(
     IJsonMasherOperator masher, Json json, IMashContext context)
 {
     if (masher is IPathGenerator generator)
     {
         foreach (var pathAndValue in generator.GeneratePaths(JsonPath.Empty, json, context))
         {
             yield return(pathAndValue);
         }
     }
     else
     {
         throw context.PushStack(masher).Error("Not a path expression.");
     }
 }
Example #4
0
 public IEnumerable <Json> Mash(Json json, IMashContext context)
 {
     context.PushStack(this).Tick();
     return(json.AsEnumerable());
 }