-3

I need help ! Can you tell me how can I get informations from this in javascript : I would like to get the Third values from the fisrt array (121,73) and also the Fourth (99,25) . Thank you in advance !


{    
    "error": [],    
    "result": {   
    "XETHZEUR": [    
        [
            1545955200,   
            "100.76",   
            "121.73",   
            "99.25",   
            "120.16",   
            "111.15",   
            "186385.05723331",   
            25420    
        ],    
        [    
            1546041600,    
            "120.52",    
            "130.00",    
            "115.91",    
            "117.89",    
            "121.47",    
            "154551.36751227",    
            23261   
        ],    
        "last": 1546387200    
    }   
}
Shubham Jain
  • 930
  • 1
  • 14
  • 24
  • 2
    This JSON is invalid: `[` on the 4th line is closed by a `}`. Please edit your question so as to include valid JSON. – Nino Filiu Jan 03 '19 at 13:41
  • Possible duplicate of [For-each over an array in JavaScript?](https://stackoverflow.com/questions/9329446/for-each-over-an-array-in-javascript) – Nicolás Carrasco-Stevenson Jan 03 '19 at 13:49
  • Hi Samuel, your question is a specific application of how to get values from a JSON Array, so I would suggest that you look into more general questions here in SO that deal with JSON parsing and/or traversing. [Here](https://stackoverflow.com/questions/9329446/for-each-over-an-array-in-javascript) is a good place to start – Nicolás Carrasco-Stevenson Jan 03 '19 at 13:51

1 Answers1

0
   var feild = {
  "error": [],
  "result": {
    "XETHZEUR": [
      [
        1545955200,
        "100.76",
        "121.73",
        "99.25",
        "120.16",
        "111.14",
        "183581.25666187",
        25053
      ],
      [
        1546041600,
        "120.16",
        "130.00",
        "115.91",
        "117.89",
        "121.48",
        "152980.08236398",
        21309
      ],
      [
        1546128000,
        "117.96",
        "123.75",
        "112.78",
        "121.99",
        "119.43",
        "108719.51659796",
        14936
      ],
      [
        1546214400,
        "121.99",
        "122.30",
        "113.00",
        "114.96",
        "118.14",
        "69796.43117029",
        9347
      ],
      [
        1546300800,
        "114.97",
        "123.90",
        "114.00",
        "122.46",
        "119.83",
        "64248.31302812",
        9713
      ],
      [
        1546387200,
        "122.62",
        "138.80",
        "121.25",
        "135.57",
        "131.69",
        "189734.68299147",
        37935
      ],
      [
        1546473600,
        "135.57",
        "136.25",
        "128.33",
        "131.45",
        "132.12",
        "67066.92874540",
        8790
      ]
    ],
    "last": 1546387200
  }
}
   let empty= [];

   feild.result.XETHZEUR.map(e=>{

     empty.push(e[2])
     empty.push(e[3])

   })


   empty.map(e=>{
     if(e=="121.73"){
       console.log(e)
     }
     if(e=="99.25"){
        console.log(e)
     }
   })
vinoth s
  • 178
  • 6
  • Of course it's working but this JSON is an API who change values all time so i can't do that : https://api.kraken.com/0/public/OHLC?interval=1440&pair=XETHZEUR&since=1545868800 – Samuel Dana Jan 03 '19 at 14:01
  • you need to get all the third and forth values in a json data ?? – vinoth s Jan 03 '19 at 14:10
  • I have update the anwser you can check if there is a any issue please let me know !!!!!1 – vinoth s Jan 03 '19 at 14:57