Skip to content

Instantly share code, notes, and snippets.

@airbreather
Last active August 26, 2017 15:54
Show Gist options
  • Save airbreather/6d7421c95896d821e32f6c7aa46ef484 to your computer and use it in GitHub Desktop.
Save airbreather/6d7421c95896d821e32f6c7aa46ef484 to your computer and use it in GitHub Desktop.
using System;
using NetTopologySuite.Features;
using NetTopologySuite.IO;
using Newtonsoft.Json.Linq;
namespace Sample
{
internal static class Program
{
private static void Main(string[] args)
{
const string geojsonFeature = @"
{
""type"": ""Feature"",
""geometry"": {
""type"": ""Point"",
""coordinates"": [125.6, 10.1]
},
""properties"": {
""name"": ""Dinagat Islands""
}
}";
var f = new GeoJsonReader().Read<Feature>(geojsonFeature);
Console.WriteLine(f.Geometry);
const string arbitraryJson = @"
{
""someArbitraryString"": ""foo""
}";
var x = JObject.Parse(arbitraryJson);
Console.WriteLine(x.GetValue("someArbitraryString"));
}
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NetTopologySuite.IO.GeoJSON" Version="1.15.0-pre015" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
</ItemGroup>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment