Skip to content

Commit 8c34c28

Browse files
jameseasterdlongley
authored andcommitted
Handle arrays of objects in developer details view.
1 parent b4124b3 commit 8c34c28

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

components/CredentialDetailsTree.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,13 @@ export default {
3333
const value = toRaw(obj[key] || obj);
3434
const node = {id: crypto.randomUUID(), label: key, children: []};
3535
if(Array.isArray(value)) {
36-
value.forEach(subValue => {
37-
createNodeList(subValue, value[subValue] || {}, node.children);
36+
// if value is an array of objects, make each key its index
37+
value.forEach((subValue, index) => {
38+
if(typeof value[0] === 'object') {
39+
createNodeList(`index ${index}`, subValue || {}, node.children);
40+
} else {
41+
createNodeList(subValue, value[subValue] || {}, node.children);
42+
}
3843
});
3944
} else if(typeof value === 'object') {
4045
Object.keys(value).forEach(subKey => {

0 commit comments

Comments
 (0)