我正在尝试从 .json 文件中获取数据并通过视图显示结果。下面是 scoreboard.json 文件。
{
"subject":"scoreboard",
"copyright":"Copyright 2015",
"data":
   "games":{
     "next_day_date":"2015-07-22",
     "modified_date":"2015-08-04T07:34:50Z",
     "month":"07",
     "year":"2015",
     "game":[
        {
           "game_type":"R",
           "double_header_sw":"N",
           "location":"Some City, State",
        }, 
        {
           "game_type":"R",
           "double_header_sw":"N",
           "location":"Another City, Another State"
        }
     ]
   }
我只想要“数据”字段而不是“主题”或“版权”字段,并且能够通过下面的 ajax 请求来实现。
	getInitialState: function() {
		return {data: []};
	},
	componentDidMount: function() {
		$.ajax({
		  url: this.props.url,
		  dataType: 'json',
		  cache: false,
		  success: function(data) {
		  	console.log(data.data);
		    this.setState({data: data.data});
		  }.bind(this),
		  error: function(xhr, status, err) {
		    console.error(this.props.url, status, err.toString());
		  }.bind(this)
		});
	},
我将状态传递给接收文件,但是,当我尝试调用它时,我收到一个 TypeError: this.props.data.map is not a function 
	render: function() {
		var gameDate = this.props.data.map(function(data) {
			return (
				<h1>{data.modified_date} </h1>
			);
		});
我希望最终能够获得 scoreboard.json 的“数据”字段中的所有信息(即 data.games.game[] 数组)。.map 函数似乎也不适用于此。
我将如何获得modified_date.map 函数中的“数据”字段(更具体地说是)?
编辑:我可以通过调用 data.games.modified_date 来记录 modified_date 但是,在尝试设置数据状态时:this.state.data = data.games.game我收到一个新警告:Each child in an array or iterator should have a unique "key" prop. Check the render method of "GameDate"