+ Reply to Thread
Results 1 to 6 of 6

Thread: Official JSON formats

  1. #1
    Denis Lapierre
    Join Date
    Feb 2012
    Posts
    7
    Points
    1
    Answers Provided
    2


    0

    Default Official JSON formats

    Hi everyone,

    I would like to know where can I find the real official JSON formats with versions.
    Is there a real standard somewhere?
    Does ESRI uses that standard?
    Where can I find the official ESRI JSON formats?
    What standard does JSON.stringify() uses?

    I have found it very difficult to find reliable information on this.

    BTW:
    My problem is that I'm trying to call a geoprocessing service on ArcGIS 10.0, but the translation from my javascript FeatureSet to JSON is not proper to what the greopressing service expect. In the request, the input has a different format and has empty values.
    Service I'm trying to call : http://oxpgisws01d.env.gov.ab.ca/Arc...tionValidation

    Thanks

  2. #2
    Andy Gup
    Join Date
    Nov 2009
    Posts
    190
    Points
    63
    Answers Provided
    12


    0

    Default Re: Official JSON formats

    @petaques, Hi, I'm not a JSON expert so I can't answer most of your questions. However, you can find detailed information on our JSON response syntax. For that information, please consult the ArcGIS Server REST API specifcation:

    http://help.arcgis.com/EN/arcgisserv...est/index.html

    Also, here's a few other links that I've found to be helpful:

    http://json.org/
    http://www.json.org/js.html


    -Andy
    Developer Evangelist
    Twitter: @agup

  3. #3
    Denis Lapierre
    Join Date
    Feb 2012
    Posts
    7
    Points
    1
    Answers Provided
    2


    0

    Default Re: Official JSON formats

    Hi, so far I didn't find any real Official JSON format (if that exist).

    I've found the ESRI JSON input format expected by a geoprocessing service for ArcGIS 10.0.
    http://help.arcgis.com/EN/arcgisserv...est/index.html
    So I know exactly what the geoprocessing service expects.

    I've also seen how a featureSet should be sent to a geoprocessing service through the submitJob function of the esri.tasks.Geoprocessor.
    http://help.arcgis.com/en/webapi/jav...oprocessor.htm

    My problem is to figure out, where does that geoprocessor find its toJson function for a featureSet.

    ESRI says that the format expected should be some like this :
    Code:
    { 
    "geometryType" : "esriGeometryPoint",
    "spatialReference" : {"wkid" : 4326},
    "features"  : [
    {
        "geometry" : {"x" : -104.44, "y" : 34.83},
        "attributes" : {"Id" : 43, "Name" : "Feature 1"}
    },
    {
        "geometry" : {"x" : -100.65, "y" : 33.69},
        "attributes" : {"Id" : 67, "Name" : "Feature 2"}
    }
    ]
    }
    But then, the geoprocessor object create the JSON from my featureSet like this:
    Code:
    {
    "fields":[],
    "geometryType":"esriGeometryPoint",
    "features":[
    {
      "geometry":{"x":678731.422659788,"y":6221057.36591139,"spatialReference":{"wkid":3400}},
      "attributes":{"ID":0,"NAME":"Main Camp","TYPE":"Permanent","LATITUDE":"56.123456","LONGITUDE":"-112.12345678","LOCAT_VALID":"Valid","isAlone":true}
    }
    ],
    "sr":{"wkid":3400}
    }
    Althought the JSON.stringify() method give me this :
    Code:
    {
    "features":[
    {
      "geometry":{"type":"point","x":678731.422659788,"y":6221057.36591139,"spatialReference":{"wkid":3400}},
      "symbol":null,
      "attributes":{"ID":0,"NAME":"Main Camp","TYPE":"Permanent","LATITUDE":"56.123456","LONGITUDE":"-112.12345678","LOCAT_VALID":"Valid","isAlone":true},
      "infoTemplate":{"title":"Main Camp","content":"Latitude: 56.123456<br>Longitude: -112.12345678"}
    }
    ],
    "geometryType":"esriGeometryPoint",
    "spatialReference":{"wkid":3400}
    }
    I've tried to call the service from the rest end point with both JSON featureSet and I found out why the JSON object created by the geoprocessor does not work. It simply that, as you can notice, the spatial reference from the geoprocessor is noted as
    Code:
    "sr":{"wkid":3400}
    while form the stringify method it is noted as
    Code:
    "spatialReference":{"wkid":3400}
    which is the expected format.

    I'm wondering if this is normal and there is just something I'm missing, or is it simply a bug from esri.tasks.geoprocessor.
    That is why I'd like to know what does the esri.tasks.geoprocessor uses for the purpose of converting FeatureSet to JSON and how can I work around that problem.

    If anyone has encountered that problem or has a hint on how to solve this, it'd be appreciated.
    Thank you
    Last edited by petaques; 05-23-2012 at 01:28 PM.

  4. #4
    Jeff Pace
    Join Date
    Jun 2010
    Posts
    904
    Points
    252
    Answers Provided
    38


    0

    Default Re: Official JSON formats

    i use http://json.org/
    and the validator at

    http://jsonformatter.curiousconcept.com/


    So far pretty straight forward, only surprise was that comments are not supported!
    You cannot have //comments in json

    you need to actually add a comments key:value pair


    Quote Originally Posted by petaques View Post
    Hi, so far I didn't find any real Official JSON format (if that exist).

    I've found the ESRI JSON input format expected by a geoprocessing service for ArcGIS 10.0.
    http://help.arcgis.com/EN/arcgisserv...est/index.html
    So I know exactly what the geoprocessing service expects.

    I've also seen how a featureSet should be sent to a geoprocessing service through the submitJob function of the esri.tasks.Geoprocessor.
    http://help.arcgis.com/en/webapi/jav...oprocessor.htm

    My problem is to figure out, where does that geoprocessor find its toJson function for a featureSet.

    ESRI says that the format expected should be some like this :
    Code:
    { 
    "geometryType" : "esriGeometryPoint",
    "spatialReference" : {"wkid" : 4326},
    "features"  : [
    {
        "geometry" : {"x" : -104.44, "y" : 34.83},
        "attributes" : {"Id" : 43, "Name" : "Feature 1"}
    },
    {
        "geometry" : {"x" : -100.65, "y" : 33.69},
        "attributes" : {"Id" : 67, "Name" : "Feature 2"}
    }
    ]
    }
    But then, the geoprocessor object create the JSON from my featureSet like this:
    Code:
    {
    "fields":[],
    "geometryType":"esriGeometryPoint",
    "features":[
    {
      "geometry":{"x":678731.422659788,"y":6221057.36591139,"spatialReference":{"wkid":3400}},
      "attributes":{"ID":0,"NAME":"Main Camp","TYPE":"Permanent","LATITUDE":"56.123456","LONGITUDE":"-112.12345678","LOCAT_VALID":"Valid","isAlone":true}
    }
    ],
    "sr":{"wkid":3400}
    }
    Althought the JSON.stringify() method give me this :
    Code:
    {
    "features":[
    {
      "geometry":{"type":"point","x":678731.422659788,"y":6221057.36591139,"spatialReference":{"wkid":3400}},
      "symbol":null,
      "attributes":{"ID":0,"NAME":"Main Camp","TYPE":"Permanent","LATITUDE":"56.123456","LONGITUDE":"-112.12345678","LOCAT_VALID":"Valid","isAlone":true},
      "infoTemplate":{"title":"Main Camp","content":"Latitude: 56.123456<br>Longitude: -112.12345678"}
    }
    ],
    "geometryType":"esriGeometryPoint",
    "spatialReference":{"wkid":3400}
    }
    I've tried to call the service from the rest end point with both JSON featureSet and I found out why the JSON object created by the geoprocessor does not work. It simply that, as you can notice, the spatial reference from the geoprocessor is noted as
    Code:
    "sr":{"wkid":3400}
    while form the stringify method it is noted as
    Code:
    "spatialReference":{"wkid":3400}
    which is the expected format.

    I'm wondering if this is normal and there is just something I'm missing, or is it simply a bug from esri.tasks.geoprocessor.
    That is why I'd like to know what does the esri.tasks.geoprocessor uses for the purpose of converting FeatureSet to JSON and how can I work around that problem.

    If anyone has encountered that problem or has a hint on how to solve this, it'd be appreciated.
    Thank you

  5. #5
    Andy Gup
    Join Date
    Nov 2009
    Posts
    190
    Points
    63
    Answers Provided
    12


    0

    Default Re: Official JSON formats

    Jeff, here's Douglas Crockford's comment on why he removed comments from JSON: https://plus.google.com/118095276221...ts/RK8qyGVaGSr

    -Andy
    Developer Evangelist
    Twitter: @agup

  6. #6
    Jeff Pace
    Join Date
    Jun 2010
    Posts
    904
    Points
    252
    Answers Provided
    38


    0

    Default Re: Official JSON formats

    Quote Originally Posted by andygup View Post
    Jeff, here's Douglas Crockford's comment on why he removed comments from JSON: https://plus.google.com/118095276221...ts/RK8qyGVaGSr

    -Andy
    THanks for the link. IT really isnt a big deal, more of just a watershed moment when "why is my json always invalid" is oh - no comments allowed!!

+ Reply to Thread

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts