Example #1
0
        public static void Run()
        {
            JsonObject jsonObject1 = ProtobufTest.read("../../json/rootProtos.json");
            JsonObject jsonObject2 = ProtobufTest.read("../../json/rootMsg.json");
            Protobuf   protobuf    = new Protobuf(jsonObject1, jsonObject1);

            foreach (string route in (IEnumerable <string>)jsonObject2.Keys)
            {
                JsonObject jsonObject3 = (JsonObject)jsonObject2[route];
                byte[]     buffer      = protobuf.encode(route, jsonObject3);
                JsonObject b           = protobuf.decode(route, buffer);
                if (!ProtobufTest.equal(jsonObject3, b))
                {
                    Console.WriteLine("protobuf test failed!");
                    return;
                }
            }
            Console.WriteLine("Protobuf test success!");
        }
Example #2
0
        public static bool equal(JsonObject a, JsonObject b)
        {
            ICollection <string> keys1 = a.Keys;
            ICollection <string> keys2 = b.Keys;

            foreach (string index in (IEnumerable <string>)keys1)
            {
                Console.WriteLine((object)a[index].GetType());
                if (a[index].GetType().ToString() == "SimpleJson.JsonObject")
                {
                    if (!ProtobufTest.equal((JsonObject)a[index], (JsonObject)b[index]))
                    {
                        return(false);
                    }
                }
                else if (!(a[index].GetType().ToString() == "SimpleJson.JsonArray") && !a[index].ToString().Equals(b[index].ToString()))
                {
                    return(false);
                }
            }
            return(true);
        }