<script>

var xmlhttp = new XMLHttpRequest();

xmlhttp.onreadystatechange = function() {
  if (this.readyState == 4 && this.status == 200) {
    var myObj = JSON.parse(this.responseText);

	mydemo=document.getElementById("demo")
	mydemo.innerHTML=JSON.stringify(myObj)+"<br>"
	
	
	thename=myObj["name"]  //put in variables
	theage=myObj["age"]
	thejob=myObj["job"]
	//thepet=myObj["pets"][0]["animal"]
	thepet=""
	
	for (j=0;j<myObj["pets"].length;j++)//or for j in myObj["pets"]
		{
		thepet=thepet+" "+(myObj["pets"][j]["animal"])
		}
		
	
	mydemo.innerHTML+=thename + " " + theage + " " + thejob +" " + thepet
	
  }
};
xmlhttp.open("GET", "3json.txt", true);
xmlhttp.send();

</script>

<div id="demo">


</div>