如何 for-each JSON 个位于同一位置的对象?

How to for-each over JSON objects located in the same place?

我正在处理一个 JSON 对象。看起来像:

Object --> text --> body --> div Array[20] --> 0
Object --> text --> body --> div Array[20] --> 1
Object --> text --> body --> div Array[20] --> ...
Object --> text --> body --> div Array[20] --> 20

所以我知道如何到达存储 20 个值的位置。 Objectname.text.body.div...但我希望能够遍历所有值,无论大小如何。我不想对所有 20 个值进行硬编码。如何遍历所有这些值?本机 JS 或 jQuery 解决方案都可以。

Objectname.text.body.div.forEach(function(entry) {
    console.log(entry);
});

有帮助吗?