我很难找到一种以我想要的方式遍历此JSON对象的方法。我在这里只使用Javascript。
首先,这是对象
{
"dialog":
{
"dialog_trunk_1":{
"message": "This is just a JSON Test"
},
"dialog_trunk_2":{
"message": "and a test of the second message"
},
"dialog_trunk_3":
{
"message": "This is a test of a bit longer text. Hopefully this will at the very least create 3 lines and trigger us to go on to another box. So we can test multi-box functionality, too."
}
}
}
现在,我只是在尝试基本方法来访问此对象上的每个dialog_trunk。理想情况下,我想遍历该对象,并为每个主干显示其message值。
我已经尝试过使用for循环动态地生成dialog_trunk的名称/编号,但是我无法使用对象名称的字符串来访问该对象,因此我不确定从这里开始。
拉丁的传说
开心每一天1111
相关分类