2017-06-04 60 views
-1

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

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"}}

如何拿到冠军?

+0

*如何拿到冠军?*通过阅读[文件](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Property_accessors)。 – 2017-06-05 02:15:00

+0

*如何获得标题?*或者为您的问题的确切标题搜索:“如何获得具有特殊字符JavaScript的对象的属性值”。 – 2017-06-05 02:34:38

回答

1

对于第一部分,可以使用括号表示法作为property accessor,然后使用Title的点表示法。

my['-KlmA9TB_CifHma9bWxn'].Title