如何在Javascript中读取值或反序列化JSON结构?

from an associative and multidimensional Array in PHP i get this object by json_encode():

{"2047":
  {"f1a":
   {"val":["7","7","6","1","6","6"],
    "cnt":6,
    "sum":33,
    "avg":5.5
   },
  {"f2a":
   {"val":["7","6","5","7","5","3","5","7","6","7"],
    "cnt":10,
    "sum":58,
    "avg":5.8
   },
  "2048": ...
}

and i want to read the value of avg of f2a and 2047.

  var myJson = {
  2047: {
    f1a: {
      val: [7, 7, 6, 1, 6, 6],
      cnt: 6,
      sum: 33,
      avg: 5.5
    },
      f2a: {
        val: [7, 6, 5, 7, 5, 3, 5, 7, 6, 7],
        cnt: 10,
        sum: 58,
        avg: 5.8
      }
  }
};
console.log(myJson['2047']['f1a']['avg']);

You can deserialize your JSON with JSON.parse (serialized)

You can use var obj = JSON.parse(str), then traverse the object using obj['2047']['f1a']