Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


How do I traverse this multidimensional JSON array/obj

Posted on 2009-05-18
Medium Priority
Last Modified: 2013-11-08
I'm creating an AJAX script with PHP, and JS.

The PHP takes GET parameters, returns some data from the database. I need this data to be usable through javascript. My php verison < 5.2 so I dont have JSON encode. So far i've been able to get PHP to format a JSON array, the data looks like the following


The first key is a uuid then the following key is another array with latitude and logitude.  I need to extract this information from javascript.
function get_map()
	var distance = $("#distance").val();
	var sort = $("input[name='sort']:checked").val(); 
	var who = $("input[name='who']:checked").val();
	$.getJSON("ajax/ajax_get_locations_map.php",{distance: ""+distance+"",who: ""+who+"",sort: ""+sort+""}, function(data){
		var obj = (data);
		$.each(obj, function(i, val) {
		     //need help at this point to get variables  

Open in new window

Question by:bperin42
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
LVL 12

Accepted Solution

alien109 earned 2000 total points
ID: 24418974
you can do this:

for(var uuid in data) {
    var lat = data[uuid].lat;
    var lng = data[uuid].lng;
//Here's what your json string looks like formatted, revealing the structure a little better

Open in new window


Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question