有9份数据,用红绿蓝黄紫青等9种颜色,每一份数据包含15个数组,15个数组按序号排列,每个数组的长度都是31,请使用一个json数组描述这9份数据。并使用js提取红的第5个数组的数据。
时间: 2023-12-18 09:02:51 浏览: 90
以下描述这9份数据的json数组:
```json
[
{
"color": "红",
"data": [
[1, 2, 3, ..., 31],
[1, 2, 3, ..., 31],
...,
[1, 2, 3, ..., 31]
]
},
{
"color": "绿",
"data": [
[1, 2, 3, ..., 31],
[1, 2, 3, ..., 31],
...,
[1, 2, 3, ..., 31]
]
},
{
"color": "蓝",
"data": [
[1, 2, 3, ..., 31],
[1, 2, 3, ..., 31],
...,
[1, 2, 3, ..., 31]
]
},
{
"color": "黄",
"data": [
[1, 2, 3, ..., 31],
[1, 2, 3, ..., 31],
...,
[1, 2, 3, ..., 31]
]
},
{
"color": "紫",
"data": [
[1, 2, 3, ..., 31],
[1, 2, 3, ..., 31],
...,
[1, 2, 3, ..., 31]
]
},
{
"color": "青",
"data": [
[1, 2, 3, ..., 31],
[1, 2, 3, ..., 31],
...,
[1, 2, 3, ..., 31]
]
},
{
"color": "橙",
"data": [
[1, 2, 3, ..., 31],
[1, 2, 3, ..., 31],
...,
[1, 2, 3, ..., 31]
]
},
{
"color": "粉",
"data": [
[1, 2, 3, ..., 31],
[1, 2, 3, ..., 31],
...,
[1, 2, 3, ..., 31]
]
},
{
"color": "灰",
"data": [
[1, 2, 3, ..., 31],
[1, 2, 3, ..., 31],
...,
[1, 2, 3, ..., 31]
]
}
]
```
使用js提取红的第5个数组的数据的代码如下:
```js
const data = [
{
"color": "红",
"data": [
[1, 2, 3, ..., 31],
[1, 2, 3, ..., 31],
...,
[1, 2, 3, ..., 31]
]
},
// 其他颜色的数据
];
const redData = data.find(item => item.color === '红').data[4];
```
阅读全文