Json嵌套数据循环
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Json嵌套数据循环相关的知识,希望对你有一定的参考价值。
我有列表ob数组json对象我试图做循环但我不能说对象仍然是空的,我试图使用嵌套的地图来呈现数据是正确的,我需要帮助来渲染这个对象,三个子数组或者也许或多或少
let d= [
[
"suit":"♥︎",
"val":"Q"
,
"suit":"♠︎",
"val":"9"
,
"suit":"♣︎",
"val":"6"
,
"suit":"♣︎",
"val":"1"
,
"suit":"♠︎",
"val":"4"
,
"suit":"♣︎",
"val":"2"
],
[
"suit":"♦︎",
"val":"3"
,
"suit":"♥︎",
"val":"2"
,
"suit":"♠︎",
"val":"5"
],[
"suit":"♠︎",
"val":"2"
,
"suit":"♦︎",
"val":"5"
,
"suit":"♠︎",
"val":"3"
]];
答案
尝试
let d=[["suit":"♥︎","val":"Q","suit":"♠︎","val":"9","suit":"♣︎","val":"6",
"suit":"♣︎","val":"1","suit":"♠︎","val":"4","suit":"♣︎","val":"2"],
["suit":"♦︎","val":"3","suit":"♥︎","val":"2","suit":"♠︎","val":"5"],
["suit":"♠︎","val":"2","suit":"♦︎","val":"5","suit":"♠︎","val":"3"]];
let s= d.map(x=>`<p>$x.map(y=>`<span>$y.val+y.suit</span>`).join('')</p>`)
document.body.innerhtml+=s.join('')
span margin-left: 20px;
以上是关于Json嵌套数据循环的主要内容,如果未能解决你的问题,请参考以下文章
在 Redshift 中取消嵌套 json 会导致查询计划中出现嵌套循环
无法让 ForEach 循环在 SwiftUI 中使用嵌套的 JSON 数据运行 [关闭]