0

I want to read data in the javascript which are received from the server in JSON format.

I've been using this a lot but now it seems that I hit the wall with this example:

JSON

{
    "results": [
        {
            "MIN(jtable.HIT_VALUE)": "70.200000",
            "AVG(jtable.HIT_VALUE)": "124.4077234969",
            "MAX(jtable.HIT_VALUE)": "1854.620000"
        }
    ]

}

JAVASCRIPT

How to read this values?

I have tried this

response.results[i].MIN(jtable.HIT_VALUE)

and I'm getting this error:

TypeError: Object #<Object> has no method 'MIN'

Any ideas?

Rene Pot
  • 24,003
  • 7
  • 67
  • 90
user123_456
  • 5,367
  • 23
  • 82
  • 138

3 Answers3

4

MIN(jtable.HIT_VALUE) is the key and has to be used as such using the square bracket notation like

response.results[i]['MIN(jtable.HIT_VALUE)']
shyam
  • 8,684
  • 4
  • 27
  • 42
1

Use it as string:

response.results[i]['MIN(jtable.HIT_VALUE)']
Rene Pot
  • 24,003
  • 7
  • 67
  • 90
1

JavaScript interprets the call response.results[i].MIN(jtable.HIT_VALUE) as an attempt to call a nonexistent function MIN.

Consider using this:

response.results[i]["MIN(jtable.HIT_VALUE)"]
potato25
  • 186
  • 5