如何显示嵌套对象中的键值对



我有这种数据结构(它更嵌套,但我给你举个例子(

{
status: {
observedGeneration: 2,
replicas: 1,
updatedReplicas: 1,
readyReplicas: 1,
availableReplicas: 1,
conditions: [
{
type: "Progressing",
status: "True",
lastUpdateTime: "2022-02-25T09:28:17Z",
lastTransitionTime: "2022-02-25T09:19:35Z",
},
{
type: "Available",
status: "True",
lastUpdateTime: "2022-09-06T02:03:09Z",
lastTransitionTime: "2022-09-06T02:03:09Z",
}
]
}
settings: {
observedGeneration: 2,
replicas: 1,
updatedReplicas: 1,
readyReplicas: 1,
availableReplicas: 1,
conditions: [
{
type: "Progressing",
status: "True",
reason: "NewReplicaSetAvailable",
message: "ReplicaSet "label-studio-546655c5cc" has successfully progressed.
},
{
type: "Available",
status: "True",
reason: "MinimumReplicasAvailable",
message: "Deployment has minimum availability."
}
]
}
}

我如何迭代以在React结构中显示类似键值对的内容。例如:

这个输出只是一个例子,但我想显示的是

`key`: `value`
`key`: `value'
`key`:
`key`:`value`
name: Mathew
seetting:
label: 1
composie: yes
additionalSetting:
performance: no
ready: onlyData
version: 123
mountPath: replices

我只是在想递归函数,但经过几个小时的挣扎,我想我需要一点帮助:(

非常感谢您提供的任何解决方案:(

正如注释中所建议的那样,您可以使用以基元值为叶的树结构。有关此类结构的示例,请参阅此代码沙盒。

最新更新