Beispiel #1
0
        public object Parse(string json)
        {
            CozyTileJsonResult node = new CozyTileJsonResult();
            JObject jo = JObject.Parse(json);
            var tiles = jo["tiles"];

            if (tiles != null && tiles.HasValues)
            {
                node.tiles = JsonConvert.DeserializeObject<List<CozyJsonTilesData>>(tiles.ToString());
            }

            var blocks = jo["blocks"];
            if (blocks != null && blocks.HasValues)
            {
                var square = blocks["square"];
                if (square != null && square.HasValues)
                {
                    node.square = JsonConvert.DeserializeObject<List<CozyJsonBlockData>>(square.ToString());
                    foreach(var obj in node.square)
                    {
                        obj.type = "square";
                    }
                }
                var rect = blocks["rect"];
                if (rect != null && rect.HasValues)
                {
                    node.rect = JsonConvert.DeserializeObject<List<CozyJsonBlockData>>(rect.ToString());
                    foreach (var obj in node.rect)
                    {
                        obj.type = "rect";
                    }
                }
            }
            return node;
        }
Beispiel #2
0
        public object Parse(string json)
        {
            CozyTileJsonResult node = new CozyTileJsonResult();
            JObject            jo   = JObject.Parse(json);
            var tiles = jo["tiles"];

            if (tiles != null && tiles.HasValues)
            {
                node.tiles = JsonConvert.DeserializeObject <List <CozyJsonTilesData> >(tiles.ToString());
            }

            var blocks = jo["blocks"];

            if (blocks != null && blocks.HasValues)
            {
                var square = blocks["square"];
                if (square != null && square.HasValues)
                {
                    node.square = JsonConvert.DeserializeObject <List <CozyJsonBlockData> >(square.ToString());
                    foreach (var obj in node.square)
                    {
                        obj.type = "square";
                    }
                }
                var rect = blocks["rect"];
                if (rect != null && rect.HasValues)
                {
                    node.rect = JsonConvert.DeserializeObject <List <CozyJsonBlockData> >(rect.ToString());
                    foreach (var obj in node.rect)
                    {
                        obj.type = "rect";
                    }
                }
            }
            return(node);
        }