FromJson() public static method

Creates a new polyline from JSON.
public static FromJson ( string json ) : Polyline
json string
return Polyline
Example #1
0
        /// <summary>
        /// Creates a new geometry from JSON.
        /// </summary>
        /// <param name="json"></param>
        /// <returns></returns>
        public static Geometry ToGeometry(string json)
        {
            if (json == null)
            {
                return(null);
            }

            if (json.Contains("x") && json.Contains("y"))
            {
                return(Point.FromJson(json));
            }
            if (json.Contains("points"))
            {
                return(Multipoint.FromJson(json));
            }
            if (json.Contains("paths"))
            {
                return(Polyline.FromJson(json));
            }
            if (json.Contains("rings"))
            {
                return(Polygon.FromJson(json));
            }

            throw new ArgumentException("This geometry type is not supported.", nameof(json));
        }