[Solved] Get one JSON value with another?


Parse it and Iterate over it

var data = JSON.parse('{"XXX":{"x":"1","y":"2"},"XXX":{"x":"3","y":"3"}}');

var y = 0;
$.each(data, function(i, item) {
    alert('With Jquery X = '+item.x);
    alert('With Jquery Y = '+item.y);
    //if you want to get the value of y based on x or vice versa then check
    if(item.x == 3) {
       y = item.y;
    }   
 });
    // Then you can use the value of y here.
    alert('This is the matching Y = '+ y);
    
    
    
    
    // With Plain Js
    for(key in data) {
  alert( 'With Plain JS X = '+data[key].x );
    alert( 'With Plain JS Y = '+data[key].y );
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

4

solved Get one JSON value with another?