AnsweredAssumed Answered

How do I access the data from this json?

Question asked by jquinada on Apr 14, 2020
Latest reply on Apr 15, 2020 by jbarry-esristaff

I am trying to access the results of the following URL in my Javascript code. The result returned is a JSON, and I'm trying to get the x and y results of that JSON.

 

Here is the URL:

https://jcgis.jacksongov.org/arcgis/rest/services/Utilities/Geometry/GeometryServer/project?inSR=102698&outSR=4326&geometries=%7B%0D%0A++%22geometryType%22+%3A+%22esriGeometryPoint%22%2C%0D%0A++%22geometries%22+%3A+%5B%0D%0A+++++%7B%0D%0A+++++++%22x%22+%3A+2806540.74997300%2C+%0D%0A+++++++%22y%22+%3A+1036617.12483400%0D%0A+++++%7D%0D%0A++%5D%0D%0A%7D&transformation=&transformForward=true&vertical=false&f=html

 

It would use GET which returns the following object:

https://jcgis.jacksongov.org/arcgis/rest/services/Utilities/Geometry/GeometryServer/project?inSR=102698&outSR=4326&geometries=%7B%0D%0A++%22geometryType%22+%3A+%22esriGeometryPoint%22%2C%0D%0A++%22geometries%22+%3A+%5B%0D%0A+++++%7B%0D%0A+++++++%22x%22+%3A+2806540.74997300%2C++++++++%22y%22+%3A+1036617.12483400%0D%0A+++++%7D%0D%0A++%5D%0D%0A%7D&transformation=&transformForward=true&vertical=false&f=pjson

 

I will actually have variables for the lat, long coordinates, but let's leave that hard-coded for the moment.

 

I have tried all sorts of methods of trying to grab the x and y results but nothing's worked. Currently I have an ajax call like this:

var lat, long, temp;
var url = "https://jcgis.jacksongov.org/arcgis/rest/services/Utilities/Geometry/GeometryServer/project?inSR=102698&outSR=4326&geometries=%7B%0D%0A++%22geometryType%22+%3A+%22esriGeometryPoint%22%2C%0D%0A++%22geometries%22+%3A+%5B%0D%0A+++++%7B%0D%0A+++++++%22x%22+%3A+2806540.74997300%2C++++++++%22y%22+%3A+1036617.12483400%0D%0A+++++%7D%0D%0A++%5D%0D%0A%7D&transformation=&transformForward=true&vertical=false&f=pjson";
$.ajax({
   dataType: 'json',
   type: "GET",
   url: url,
   success: function(jsonobject)
   {
      temp = JSON.parse(jsonobject);
      lat = temp.geometries.x;
      long = temp.geometries.y;
   }
});

I am not sure I am using the parse correctly, but looking at examples in various places online I'm not sure how else it should be done. When I try to run the code the only result I get is "undefined."

 

What am I missing?

Outcomes