From 33a9c5a29fbc37aef015c49e8b983be8ccf5a3ea Mon Sep 17 00:00:00 2001 From: Brent Zundel Date: Sat, 9 Sep 2023 04:09:24 -0700 Subject: [PATCH] Add guidance around arrays. Co-authored-by: Ted Thibodeau Jr Co-authored-by: Orie Steele Co-authored-by: Manu Sporny --- index.html | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index db34f17b9..1893fab43 100644 --- a/index.html +++ b/index.html @@ -4031,7 +4031,64 @@

Syntactic Sugar

- +
+

Lists and Arrays

+

+Lists, arrays, and even lists of lists, are possible when using [[JSON-LD]] 1.1. +We encourage those who want RDF semantics in use +cases requiring lists and arrays to follow the guidance on +lists in JSON-LD 1.1. +

+

+In general, a JSON array is ordered, while a JSON-LD array is not ordered unless +that array uses the @list keyword. +

+

+While it is possible to use this data model without any JSON-LD processing, +those who do so and make use of arrays need to be aware that unless the above +guidance is followed, the order of items in an array cannot be guaranteed in +JSON-LD. This might lead to unexpected behavior. +

+

+If JSON structure or ordering is important to your application, +we recommend you mark such elements as `@json` via an `@context`. +

+
+{
+  "@context":
+    {
+      "matrix": {
+        "@id": "https://website.example/vocabulary#matrix",
+        "@type": "@json"
+      }
+    }
+}
+          
+
+{
+  "@context": [
+    "https://www.w3.org/ns/credentials/v2",
+    "https://www.w3.org/ns/credentials/examples/v2",
+    "https://website.example/matrix/v1"
+  ],
+  "id": "http://university.example/credentials/1872",
+  "type": [
+    "VerifiableCredential",
+    "ExampleMatrixCredential"
+  ],
+  "issuer": "https://university.example/issuers/565049",
+  "validFrom": "2010-01-01T19:23:24Z",
+  "credentialSubject": {
+    "id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
+    "matrix": [
+      [1,2,3,4,5,6,7,8,9,10,11,12], 
+      [1,1,1,1,1,1,1,1,0,0,0,0],
+      [0,0,1,1,1,1,1,1,1,0,0,0]
+    ]
+  }
+}
+          
+

Media Types