Ejemplo n.º 1
0
        internal override bool ExecuteB(JsonObject json, JsonObject parent)
        {
            JsonValue old = WokeJ.GetElementByKey(json, Key);

            if (old == null)
            {
                return(false);
            }
            if (old is JsonPrimitive oldP)
            {
                json[Key] = ExecuteE(oldP, json, parent);
                return(old != json[Key]);
            }
            else if (old is JsonArray oldA)
            {
                // TODO
                return(false);
                //WokeJ.ForAllElements(oldA, e => ExecuteB(e, parent));
                //return true; // overapproximation
            }
            else
            if (Config.Debug)
            {
                Console.WriteLine($"[ERROR] Cannot truncate a dictionary, skipped");
            }
            return(false);
        }
Ejemplo n.º 2
0
        internal override bool ExecuteB(JsonObject json, JsonObject parent)
        {
            JsonValue old = WokeJ.GetElementByKey(json, Key);

            if (old == null)
            {
                return(false);
            }
            if (old is JsonPrimitive oldP)
            {
                json[Key] = ExecuteE(oldP, json, parent);
                return(old != json[Key]);
            }
            else if (old is JsonArray oldA)
            {
                Console.WriteLine($"got to the array {oldA}");
                WokeJ.MapReduce(oldA, e => e is JsonPrimitive ep ? ExecuteE(ep, json, parent) : e);
                return(true); // overapproximation
            }
            else
            if (Config.Debug)
            {
                Console.WriteLine($"[ERROR] Cannot truncate a dictionary, skipped");
            }
            return(false);
        }
Ejemplo n.º 3
0
        internal override bool ExecuteB(JsonObject json, JsonObject parent)
        {
            JsonValue old = WokeJ.GetElementByKey(json, Key);

            if (old == null)
            {
                return(false);
            }
            json.Remove(Key);
            return(true);
        }
Ejemplo n.º 4
0
 internal override JsonPrimitive ExecuteE(JsonPrimitive jp, JsonValue json, JsonValue parent)
 {
     if (Value[0] == '$')
     {
         return(new JsonPrimitive(IO.BareValue(WokeJ.GetElementByKey(json, Value.Substring(1)))));
     }
     else
     {
         return(new JsonPrimitive(Value));
     }
 }
Ejemplo n.º 5
0
        internal override bool ExecuteB(JsonObject json, JsonObject parent)
        {
            JsonValue old = WokeJ.GetElementByKey(json, Key);

            if (Value[0] == '$')
            {
                return(_assign(old, json, parent, Key, IO.BareValue(WokeJ.GetElementByKey(json, Value.Substring(1)))));
            }
            else
            {
                return(_assign(old, json, parent, Key, Value));
            }
        }
Ejemplo n.º 6
0
        internal override bool ExecuteB(JsonObject json, JsonObject parent)
        {
            JsonValue old = WokeJ.GetElementByKey(json, Key);
            JsonValue neu = WokeJ.GetElementByKey(parent, ParentKey);

            if (neu != null)
            {
                WokeJ.AddKeyValue(json, Key, neu);
                return(WokeJ.GetElementByKey(json, Key) != old);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 7
0
        internal override bool ExecuteB(JsonObject json, JsonObject parent)
        {
            if (json == null)
            {
                if (Config.Debug)
                {
                    Console.WriteLine("[ERROR] Cannot rename something outside a dictionary");
                }
                return(false);
            }
            var old = WokeJ.GetElementByKey(json, KeyOld);

            if (old == null)
            {
                return(false);
            }
            WokeJ.AddKeyValue(json, KeyNew, old);
            json.Remove(KeyOld);
            return(true); // overapptoximation
        }