<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Convert Geomtry to Json in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/convert-geomtry-to-json/m-p/1167333#M20457</link>
    <description>&lt;P&gt;Here is my final code. The doc's are real bad , no samples and every small change gives catastrophic error with no error message.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have fun&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; private string geo2json(IFeature feature)
        {
            IJSONWriter jsonWriter = new JSONWriterClass();
            jsonWriter.WriteToString();
            IJSONSerializer jsonSerializer = new JSONSerializerGdb();
            IPropertySet props = new PropertySetClass();
            props.SetProperty("Format", "GeoJSON");
            jsonSerializer.InitSerializer(jsonWriter, props);
            ((IExternalSerializerGdb)jsonSerializer).WriteGeometry(null, feature.Shape);

            var geoJson = Encoding.UTF8.GetString(jsonWriter.GetStringBuffer());

            return geoJson;
          
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 24 Apr 2022 14:17:28 GMT</pubDate>
    <dc:creator>mody_buchbinder</dc:creator>
    <dc:date>2022-04-24T14:17:28Z</dc:date>
    <item>
      <title>Convert Geomtry to Json</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/convert-geomtry-to-json/m-p/1164343#M20449</link>
      <description>&lt;P&gt;In arcpy you just do geometry.JSON to get the json string for it.&lt;/P&gt;&lt;P&gt;I could not find a simple way to do the same in ArcObjects.&lt;/P&gt;&lt;P&gt;Convert single geometry (not in feature class) into json (or GeoJson) string.&lt;/P&gt;&lt;P&gt;The GeometryEngine in Pro SDK have ExportToJson.&lt;/P&gt;&lt;P&gt;Anybody?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 11:24:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/convert-geomtry-to-json/m-p/1164343#M20449</guid>
      <dc:creator>mody_buchbinder</dc:creator>
      <dc:date>2022-04-14T11:24:25Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Geomtry to Json</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/convert-geomtry-to-json/m-p/1164681#M20450</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;If you use ArcObjects .NET SDK 10.8 you can use&amp;nbsp;&lt;A href="https://desktop.arcgis.com/en/arcobjects/latest/net/webframe.htm#JSONConverterGdb.htm" target="_self"&gt;JSONConverterGdb class&lt;/A&gt;&amp;nbsp;. I don't know if it is available in earlier versions.&lt;/P&gt;&lt;P&gt;Another way is to use .NET serializer:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        public static string To&amp;lt;T&amp;gt;(T obj)
        {
            string retVal = null;
            System.Runtime.Serialization.Json.DataContractJsonSerializer serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(obj.GetType());
            using (MemoryStream ms = new MemoryStream())
            {
                serializer.WriteObject(ms, obj);
                retVal = Encoding.Default.GetString(ms.ToArray());
            }

            return retVal;
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Apr 2022 05:35:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/convert-geomtry-to-json/m-p/1164681#M20450</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2022-04-15T05:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Geomtry to Json</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/convert-geomtry-to-json/m-p/1164998#M20451</link>
      <description>&lt;P&gt;I will give it a try.&lt;/P&gt;&lt;P&gt;I checked the ArcObjects JSONConverterGdb but as far as I understand it gets a Table and not single geometry. I will have to create a temporary table and gets all the attributes and not only geometry.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Apr 2022 12:03:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/convert-geomtry-to-json/m-p/1164998#M20451</guid>
      <dc:creator>mody_buchbinder</dc:creator>
      <dc:date>2022-04-17T12:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Geomtry to Json</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/convert-geomtry-to-json/m-p/1165532#M20452</link>
      <description>&lt;P&gt;There is method for geometry serializing:&lt;/P&gt;&lt;P&gt;&lt;A href="https://desktop.arcgis.com/en/arcobjects/latest/net/webframe.htm#IExternalSerializerGdb_WriteGeometry.htm" target="_blank"&gt;- IExternalSerializerGdb.WriteGeometry Method (ArcObjects .NET 10.8 SDK) (arcgis.com)&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2022 05:22:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/convert-geomtry-to-json/m-p/1165532#M20452</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2022-04-19T05:22:57Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Geomtry to Json</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/convert-geomtry-to-json/m-p/1167333#M20457</link>
      <description>&lt;P&gt;Here is my final code. The doc's are real bad , no samples and every small change gives catastrophic error with no error message.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have fun&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; private string geo2json(IFeature feature)
        {
            IJSONWriter jsonWriter = new JSONWriterClass();
            jsonWriter.WriteToString();
            IJSONSerializer jsonSerializer = new JSONSerializerGdb();
            IPropertySet props = new PropertySetClass();
            props.SetProperty("Format", "GeoJSON");
            jsonSerializer.InitSerializer(jsonWriter, props);
            ((IExternalSerializerGdb)jsonSerializer).WriteGeometry(null, feature.Shape);

            var geoJson = Encoding.UTF8.GetString(jsonWriter.GetStringBuffer());

            return geoJson;
          
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 24 Apr 2022 14:17:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/convert-geomtry-to-json/m-p/1167333#M20457</guid>
      <dc:creator>mody_buchbinder</dc:creator>
      <dc:date>2022-04-24T14:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Geomtry to Json</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/convert-geomtry-to-json/m-p/1340806#M20611</link>
      <description>&lt;P&gt;Another way to do the work is to use&amp;nbsp;JSONConverterGeometry:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;IJSONConverterGeometry JSONConverterGeometry = new JSONConverterGeometryClass();
IJSONObject JSONGeometry = new JSONObjectClass();
JSONConverterGeometry.QueryJSONGeometry(geometry, true, JSONGeometry);
string strGeometry = JSONGeometry.ToJSONString(null);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe a litlle bit simplier ...&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2023 15:53:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/convert-geomtry-to-json/m-p/1340806#M20611</guid>
      <dc:creator>FredericWalter</dc:creator>
      <dc:date>2023-10-26T15:53:54Z</dc:date>
    </item>
  </channel>
</rss>

