Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix expansion when @set or @list includes @annotation.

  • Loading branch information...
commit efc267a66a6d2ac2ea8f9c70ed075c1eaa13051e 1 parent eaefa26
@gkellogg authored
View
3  lib/json/ld/expand.rb
@@ -238,7 +238,8 @@ def expand(input, active_property, context, namer, options = {})
# If element has an @set or @list property, it must be the only property. Set element to the value of @set;
# leave @list untouched.
if !(%w(@set @list) & output_object.keys).empty?
- raise ProcessingError, "element must have only @set, @list or @graph" if output_object.keys.length > 1
+ o_keys = output_object.keys - %w(@set @list @annotation)
+ raise ProcessingError, "element must have only @set or @list: #{output_object.keys.inspect}" if o_keys.length > 1
output_object = output_object.values.first unless output_object.has_key?('@list')
end
View
6 spec/test-files/test-7-compacted.json
@@ -2,19 +2,19 @@
"@context": { "foaf": "http://xmlns.com/foaf/0.1/" },
"@graph": [
{
- "@id": "_:bnode1",
+ "@id": "_:t0",
"@type": "foaf:Person",
"foaf:homepage": "http://example.com/bob/",
"foaf:name": "Bob"
},
{
- "@id": "_:bnode2",
+ "@id": "_:t1",
"@type": "foaf:Person",
"foaf:homepage": "http://example.com/eve/",
"foaf:name": "Eve"
},
{
- "@id": "_:bnode3",
+ "@id": "_:t2",
"@type": "foaf:Person",
"foaf:homepage": "http://example.com/manu/",
"foaf:name": "Manu"
View
6 spec/test-files/test-7-expanded.json
@@ -1,18 +1,18 @@
[
{
- "@id": "_:bnode1",
+ "@id": "_:t0",
"@type": ["http://xmlns.com/foaf/0.1/Person"],
"http://xmlns.com/foaf/0.1/homepage": [{"@value": "http://example.com/bob/"}],
"http://xmlns.com/foaf/0.1/name": [{"@value": "Bob"}]
},
{
- "@id": "_:bnode2",
+ "@id": "_:t1",
"@type": ["http://xmlns.com/foaf/0.1/Person"],
"http://xmlns.com/foaf/0.1/homepage": [{"@value": "http://example.com/eve/"}],
"http://xmlns.com/foaf/0.1/name": [{"@value": "Eve"}]
},
{
- "@id": "_:bnode3",
+ "@id": "_:t2",
"@type": ["http://xmlns.com/foaf/0.1/Person"],
"http://xmlns.com/foaf/0.1/homepage": [{"@value": "http://example.com/manu/"}],
"http://xmlns.com/foaf/0.1/name": [{"@value": "Manu"}]
Please sign in to comment.
Something went wrong with that request. Please try again.