Deserialize() public method

public Deserialize ( string key, IJSONSerializable json ) : void
key string /// A ///
json IJSONSerializable /// A ///
return void
Example #1
0
        public void JSONDeserialize(JSONDeserializer deser)
        {
            if (AnotherCar != null)
                deser.Deserialize("child car", AnotherCar);
            name = deser.DeserializeString("name");
            color = deser.DeserializeString("color");
            wheels = (int)deser.DeserializeInteger("wheels");
            owner = deser.DeserializeString("owner");

            deser.DeserializeArrayBegin("array");
            for (int i = 1; i <= deser.DeserializeArraySize(); ++i)
            {
                deser.DeserializeArrayBegin();
                for (int j = 1; j <= deser.DeserializeArraySize(); ++j)
                    deser.DeserializeInteger();
                deser.DeserializeArrayEnd();
            }
            deser.DeserializeArrayEnd();
        }
Example #2
0
        public static void Main(string[] args)
        {
            JSONSerializer serializer = new JSONSerializer();
            Car car = new Car("wrong", "Red", 4, "Me!");
            car.AnotherCar = new Car("wrong", "White", 4, "Wife");
            car.AnotherCar.AnotherCar = new Car("wrong", "Red", 0, "No one");

            serializer.Serialize("car", car);

            serializer.Save("data.json");

            JSONDeserializer deserializer = new JSONDeserializer("data.json");

            deserializer.Deserialize("car", car);

            Console.WriteLine("{0} {1} {2}", car.name, car.AnotherCar.name, car.AnotherCar.AnotherCar.name);
        }