Skip to content

Commit 1318b71

Browse files
committed
Simplification when compacting lists.
1 parent b8c47b5 commit 1318b71

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

lib/json/ld/compact.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ def compact(element, property: nil, ordered: false)
105105
(context.as_array?(kw_alias) &&
106106
!value?(element) &&
107107
context.processingMode('json-ld-1.1'))
108-
compacted_value = compacted_value.first unless as_array
109-
result[kw_alias] = compacted_value
108+
add_value(result, kw_alias, compacted_value, property_is_array: as_array)
110109
next
111110
end
112111

@@ -272,7 +271,6 @@ def compact(element, property: nil, ordered: false)
272271
index_key = context.term_definitions[item_active_property].index || '@index'
273272
if index_key == '@index'
274273
map_key = expanded_item['@index']
275-
compacted_item.delete(container_key) if compacted_item.is_a?(Hash)
276274
else
277275
container_key = context.compact_iri(index_key, vocab: true)
278276
map_key, *others = Array(compacted_item[container_key])

0 commit comments

Comments
 (0)