locked
How to define JSON objects RRS feed

  • Question

  •  Hi,

    just started to work with JSON. but i have some problems with the definition on how to define classes in .net
    this is my JSON object and i don't have any problems with the first couple of classes but i have no idea on how the features class would look like

    {
    "displayFieldName" : "Name",
    "fieldAliases" : {
    "NAME" : "NAME"
    },
    "geometryType" : "esriGeometryPolygon",
    "spatialReference" : {
    "wkid" : 54004
    },
    "features" : [
    {
    "attributes" : {
    "NAME" : "Netherlands"
    },
    "geometry" :
    {
    "rings" :
    [
    [
    [6.13844600000004, 53.49395],
    [6.27447000000006, 53.5056700000001],
    [6.30730300000005, 53.49629],
    [6.23694600000005, 53.46815],
    [6.15486200000004, 53.46581],
    [6.12672000000009, 53.4493900000001],
    [6.10092200000008, 53.46581],
    [6.13844600000004, 53.49395]
    ],
    [
    [714657.327300001, 7049283.3154],
    [721706.1888, 7045339.2012],
    [715440.3486, 7044465.0747],
    [712046.5513, 7047969.6368],
    [714657.327300001, 7049283.3154]
    ]
    ]
    }
    }
    ]
    }

    so does anyone have an idea or example on how the class features should look like ty in advances

    Thursday, November 20, 2008 4:36 AM

Answers

  • it's a 3 dimensional array of integers, a cube of integers.

    it's an array of array of array of int's.

    so try with this:

    public class geometryType 

       public int[][][] rings { get; set;}

    Thursday, November 20, 2008 10:44 AM

All replies

  • I am not sure about the ringsType class

     

     

    public class FieldAliasesType

    {

      public string NAME { get; set; }
    }

    public class spatialReferenceType

    {

    public int wkid { get; set; }

    }

     

    public class Feature

    {

        public attributesType attributes { get; set; }
     }

     

    public class attributesType


            public string NAME { get; set; }
     }

     

    public class geometryType 

       public ringsType rings   { get; set;}

     

     

    public class MyClass

     {
    public string displayFieldName { get; set; }

    public FieldAliasesType fieldAliases : { get; set; }

    public string geometryType
    { get; set; }
    public
    spatialReferenceType spatialReference { get; set; }

    public Feature[ ] features { get; set; }

    }

    Thursday, November 20, 2008 7:26 AM
  • Thanks for your reply, but the problem is the feature/rings class :D the rest is not realy an problem
    Thursday, November 20, 2008 9:55 AM
  • it's a 3 dimensional array of integers, a cube of integers.

    it's an array of array of array of int's.

    so try with this:

    public class geometryType 

       public int[][][] rings { get; set;}

    Thursday, November 20, 2008 10:44 AM
  •  did it work ?

    Thursday, November 20, 2008 2:46 PM
  • It did work except its not an int but double :D ty guys for the fast response
    Friday, November 21, 2008 4:07 AM
  •  right :)

     In fact, it's 3D coordinates I think 

    Friday, November 21, 2008 4:10 AM