如何获取具有特殊字符的对象的属性值

时间:2017-06-04 08:59:06

标签: javascript



my = {"-KlmA9TB_CifHma9bWxn":{"CreatedAt":1496564148575,"Description":"heoeoealskd","Location":[{"address_components":[{"long_name":"Unnamed Road","short_name":"Unnamed Road","types":["route"]},{"long_name":"Pigcawayan","short_name":"Pigcawayan","types":["locality","political"]},{"long_name":"Cotabato","short_name":"Cotabato","types":["administrative_area_level_2","political"]},{"long_name":"Region XII","short_name":"SOCCSKSARGEN","types":["administrative_area_level_1","political"]},{"long_name":"Philippines","short_name":"PH","types":["country","political"]}],"formatted_address":"Unnamed Road, Pigcawayan, Cotabato, Philippines","geometry":{"bounds":{"b":{"b":124.46047069999997,"f":124.46153930000003},"f":{"b":7.3554572,"f":7.357102899999999}},"location_type":"GEOMETRIC_CENTER","viewport":{"b":{"b":124.45965601970852,"f":124.46235398029148},"f":{"b":7.354931069708498,"f":7.357629030291503}}},"place_id":"ChIJZxrsUfQeVjIRps6uMIrHmJA","types":["route"]},{"address_components":[{"long_name":"Pigcawayan","short_name":"Pigcawayan","types":["locality","political"]},{"long_name":"Cotabato","short_name":"Cotabato","types":["administrative_area_level_2","political"]},{"long_name":"Region XII","short_name":"SOCCSKSARGEN","types":["administrative_area_level_1","political"]},{"long_name":"Philippines","short_name":"PH","types":["country","political"]}],"formatted_address":"Pigcawayan, Cotabato, Philippines","geometry":{"bounds":{"b":{"b":124.33264009999994,"f":124.49243550000006},"f":{"b":7.1655978,"f":7.4460498}},"location_type":"APPROXIMATE","viewport":{"b":{"b":124.33297119999997,"f":124.49243550000006},"f":{"b":7.166007,"f":7.4460498}}},"place_id":"ChIJxz8zvYYhVjIRP3HyqSG6PZY","types":["locality","political"]},{"address_components":[{"long_name":"Cotabato","short_name":"Cotabato","types":["administrative_area_level_2","political"]},{"long_name":"Region XII","short_name":"SOCCSKSARGEN","types":["administrative_area_level_1","political"]},{"long_name":"Philippines","short_name":"PH","types":["country","political"]}],"formatted_address":"Cotabato, Philippines","geometry":{"bounds":{"b":{"b":124.33343489999993,"f":125.31497000000002},"f":{"b":6.7588269,"f":7.681884999999999}},"location_type":"APPROXIMATE","viewport":{"b":{"b":124.33343489999993,"f":125.31497000000002},"f":{"b":6.7588269,"f":7.681884999999999}}},"place_id":"ChIJEzcr9xjr-DIRX4BHpgoSE8o","types":["administrative_area_level_2","political"]},{"address_components":[{"long_name":"Region XII","short_name":"SOCCSKSARGEN","types":["administrative_area_level_1","political"]},{"long_name":"Philippines","short_name":"PH","types":["country","political"]}],"formatted_address":"Region XII, Philippines","geometry":{"bounds":{"b":{"b":124.01451199999997,"f":125.53578590000006},"f":{"b":5.564068,"f":7.682324999999999}},"location_type":"APPROXIMATE","viewport":{"b":{"b":124.01560340000003,"f":125.53578590000006},"f":{"b":5.5664906,"f":7.682324999999999}}},"place_id":"ChIJi5rGCnMU-DIR59ey-3ltPlI","types":["administrative_area_level_1","political"]},{"address_components":[{"long_name":"Philippines","short_name":"PH","types":["country","political"]}],"formatted_address":"Philippines","geometry":{"bounds":{"b":{"b":116.14749989999996,"f":127.64447840000003},"f":{"b":4.2259,"f":19.932}},"location_type":"APPROXIMATE","viewport":{"b":{"b":114.583481,"f":130.66002750000007},"f":{"b":3.6346296,"f":19.7610407}}},"place_id":"ChIJY96HXyFTQDIRV9opeu-QR3g","types":["country","political"]}],"Poster":"OBY1Ab40wQQLWhMHuvb32KrbOx82","Status":"active","Title":"helo","id":"-KlmA9TB_CifHma9bWxn"}}




如何获得头衔?

1 个答案:

答案 0 :(得分:1)

您可以将括号表示法用作property accessor作为第一部分,然后使用点符号表示Title

my['-KlmA9TB_CifHma9bWxn'].Title