Skip to content

Commit 151bd87

Browse files
authored
feat: Normalize nested objects (#295)
* Normalize nested objects When using normalization groups to expose some properties of a nested object, the current code only retrieves the IRI. It seems interesting to be able to normalize the nested item if it is an object, and return the real object instead of a string IRI. * Update dataAccess.js
1 parent 096f7fd commit 151bd87

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

templates/react-common/utils/dataAccess.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ export function normalize(data) {
6565
// Flatten nested documents
6666
return mapValues(data, value =>
6767
Array.isArray(value)
68-
? value.map(v => get(v, '@id', v))
68+
? value.map(v => normalize(v))
69+
: value instanceof Object ? normalize(value)
6970
: get(value, '@id', value)
7071
);
7172
}

0 commit comments

Comments
 (0)