Update compaction algorithm to remove @graph from output when it is empty and the only member
authorMarkus Lanthaler <mark_lanthaler@gmx.net>
Thu, 24 Jan 2013 20:05:52 +0100
changeset 1154 acd4b6c998b6
parent 1153 a2cea9301e46
child 1155 7fbd03949c51
Update compaction algorithm to remove @graph from output when it is empty and the only member

See https://github.com/json-ld/json-ld.org/issues/99#issuecomment-5048471 and the discussion in 87a4681c35748ff92d2912e2fc480ca957c5cf5f.
spec/latest/json-ld-api/index.html
--- a/spec/latest/json-ld-api/index.html	Thu Jan 24 19:35:27 2013 +0100
+++ b/spec/latest/json-ld-api/index.html	Thu Jan 24 20:05:52 2013 +0100
@@ -1403,10 +1403,12 @@
   </ol>
 
   <p>If, after the algorithm outlined above is run, the resulting <em>element</em> is an <tref>array</tref>
-    replace it with a new <tref>JSON object</tref> with a single member whose name is the result of
-    compacting the value <code>@graph</code> with the <a href="#iri-compaction-algorithm">IRI Compaction algorithm</a>
-    and whose value is <em>element</em>. Finally, add a <code>@context</code> property to <em>element</em>
-    and set it to the initially passed <em>context</em>.</p>
+    with one or more items, replace it with a new <tref>JSON object</tref> with a single member whose name
+    is the result of compacting the value <code>@graph</code> with the
+    <a href="#iri-compaction-algorithm">IRI Compaction algorithm</a> and whose value is <em>element</em>. If
+    the resulting <em>element</em> is an <tref>array</tref> with zero items, replace it with an empty
+    <tref>JSON object</tref>. Finally, if a <em>context</em> has been passed, add a <code>@context</code>
+    property to <em>element</em> and set its value to the initially passed <em>context</em>.</p>
 </section>
 
 <section>