Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在javascript中从arraylist对象中删除内括号_Javascript_Object_Arraylist_Iterator - Fatal编程技术网

如何在javascript中从arraylist对象中删除内括号

如何在javascript中从arraylist对象中删除内括号,javascript,object,arraylist,iterator,Javascript,Object,Arraylist,Iterator,我只想从下面的arrayList中删除一个额外的括号: [ { "small":"https://www.googleapis.com/photo.png?", "medium":"https://www.googleapis.com/photo.png?", "big":"https://www.googleapis.com/photo.png?" }, [ { "small":"https://www.googleapis.com/Jenner.jfif?", "medium":"https

我只想从下面的arrayList中删除一个额外的括号:

[
{
"small":"https://www.googleapis.com/photo.png?",
"medium":"https://www.googleapis.com/photo.png?",
"big":"https://www.googleapis.com/photo.png?"
},
[
{
"small":"https://www.googleapis.com/Jenner.jfif?",
"medium":"https://www.googleapis.com/Jenner.jfif?",
"big":"https://www.googleapis.com/Jenner.jfif?"
}
]
]

to 

[
{
"small":"https://www.googleapis.com/photo.png?",
"medium":"https://www.googleapis.com/photo.png?",
"big":"https://www.googleapis.com/photo.png?"
},
{
"small":"https://www.googleapis.com/Jenner.jfif?",
"medium":"https://www.googleapis.com/Jenner.jfif?",
"big":"https://www.googleapis.com/Jenner.jfif?"
}
]
请帮我解决这个……谢谢 像这样的事

它将原始数组和每个元素带到一个新数组中。如果一个原始元素是一个数组(它有“额外的括号”),那么它不会跨数组复制值,而是只复制该数组的第一个元素,有效地“删除括号”。我想这就是你要找的

var a=[
{
“小”:https://www.googleapis.com/photo.png?",
“中等”:https://www.googleapis.com/photo.png?",
“大”:https://www.googleapis.com/photo.png?"
},
[
{
“小”:https://www.googleapis.com/Jenner.jfif?",
“中等”:https://www.googleapis.com/Jenner.jfif?",
“大”:https://www.googleapis.com/Jenner.jfif?"
}
]
];
a=a.map(元素=>{
if(elem.constructor==数组){
返回元素[0];
}否则{
返回元素;
}
});
控制台日志(a)