Geometry JSON Online

This sample demonstrates techniques for converting managed Geometry, such as MapPoint, Polyline, and Polygon to and from ArcGIS JSON. ArcGIS JSON geometry is defined as part of the ArcGIS Server REST API specification: http://resources.arcgis.com/en/help/rest/apiref/geometry.html. Use the buttons at the top of "From JSON" tab to populate the textbox on the tab with predefined geometry JSON. Feel free to modify the JSON content appropriately and add or update a graphic in the map with new geometry. Use the "To JSON" tab to add a graphic to the map that references MapPoint, Polyline, Polygon, or Envelope geometry. JSON for the geometry of the graphic added to the map will be displayed. Note, only one graphic is displayed in the map at a time. Switching between tabs will clear all graphics layers in the map.

Download Sample Application
XAML C# VB.NET
<UserControl x:Class="ArcGISWPFSDK.GeometryJson"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"    
    xmlns:esri="http://schemas.esri.com/arcgis/client/2009">
    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.Resources>
            <esri:SimpleMarkerSymbol x:Key="RedMarkerSymbol" Color="Red" Size="12" Style="Circle" />
            <esri:SimpleLineSymbol x:Key="RedLineSymbol" Color="Red" Width="4" Style="Solid" />
            <esri:SimpleFillSymbol x:Key="RedFillSymbol" Fill="#66FF0000" BorderBrush="Red" BorderThickness="2" />
            <esri:SimpleMarkerSymbol x:Key="BlueMarkerSymbol" Color="Blue" Size="12" Style="Circle" />
            <esri:SimpleLineSymbol x:Key="BlueLineSymbol" Color="Blue" Width="4" Style="Solid" />
            <esri:SimpleFillSymbol x:Key="BlueFillSymbol" Fill="#660000FF" BorderBrush="Blue" BorderThickness="2" />
            <esri:SimpleLineSymbol x:Key="DrawLineSymbol" Color="Green" Width="4" />
            <esri:SimpleFillSymbol x:Key="DrawFillSymbol" Fill="#3300FF00" BorderBrush="Green" BorderThickness="2" />
        </Grid.Resources>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <esri:Map x:Name="MyMap" UseAcceleratedDisplay="True"  WrapAround="True" Grid.Column="0">
            <esri:ArcGISTiledMapServiceLayer ID="TiledLayer" 
                Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer" />
            <esri:GraphicsLayer ID="MyToJsonGraphicsLayer" />
            <esri:GraphicsLayer ID="MyFromJsonGraphicsLayer" />
        </esri:Map>
        <TabControl Margin="5" Grid.Column="1" Background="White" VerticalAlignment="Stretch" 
                        SelectionChanged="TabControl_SelectionChanged">
            <TabItem Header="From JSON">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="50" />
                        <RowDefinition />
                        <RowDefinition Height="40" />
                    </Grid.RowDefinitions>
                    <StackPanel Grid.Row="0" Orientation="Vertical" Margin="5" Background="LightGray">
                        <TextBlock Text="Sample JSON" FontWeight="Bold" Margin="2" />
                        <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                            <Button Content="Point" Width="80" Margin="2" Click="PointJsonButton_Click" />
                            <Button Content="Polyline" Width="80" Margin="2" Click="PolylineJsonButton_Click" />
                            <Button Content="Polygon" Width="80" Margin="2" Click="PolygonJsonButton_Click" />
                            <Button Content="Envelope" Width="80" Margin="2" Click="EnvelopeJsonButton_Click" />
                        </StackPanel>
                    </StackPanel>
                    <ScrollViewer Grid.Row="1">
                        <TextBox x:Name="InJsonTextBox" FontSize="12" TextWrapping="Wrap" />
                    </ScrollViewer>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" Grid.Row="2">
                        <Button Content="Create Geometry from JSON" Margin="5" Width="150" Click="ApplyButton_Click"  />
                        <Button Content="Reset" Margin="5" Width="150" Click="ResetButton_Click" />
                    </StackPanel>
                </Grid>
            </TabItem>
            <TabItem Header="To JSON">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="50" />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch">
                        <StackPanel Orientation="Vertical">
                            <StackPanel Orientation="Horizontal" >
                                <Button Content="Add Point" Width="80" Margin="2" Click="DrawGeometryButton_Click" Tag="DrawPoint" />
                                <Button Content="Add Polyline" Width="80" Margin="2" Click="DrawGeometryButton_Click" Tag="DrawPolyline" />
                            </StackPanel>
                            <StackPanel Orientation="Horizontal" >
                                <Button Content="Add Polygon" Width="80" Margin="2" Click="DrawGeometryButton_Click" Tag="DrawPolygon" />
                                <Button Content="Add Envelope" Width="80" Margin="2" Click="DrawGeometryButton_Click" Tag="DrawRectangle" />
                            </StackPanel>
                        </StackPanel>
                        <Button Content="Reset" Margin="5" Width="150" Click="ResetButton_Click" />
                    </StackPanel>
                    <ScrollViewer Grid.Row="1">
                        <TextBox x:Name="OutJsonTextBox" TextWrapping="Wrap" IsReadOnly="True" />
                    </ScrollViewer>
                </Grid>
            </TabItem>
        </TabControl>
    </Grid>
</UserControl>

Sample code usage restrictions
5/16/2014