Deserialization of new json-ld format
diff --git a/src/test/resources/queries/bsp-class.jsonld b/src/test/resources/queries/bsp-class.jsonld
new file mode 100644
index 0000000..f036535
--- /dev/null
+++ b/src/test/resources/queries/bsp-class.jsonld
@@ -0,0 +1,36 @@
+{
+  "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "query":{
+    "@type":"korap:group",
+    "operation" : "operation:class",
+   "class":0,
+    "operands":[
+      {
+	"@type":"korap:group",
+	"operation" : "operation:sequence",
+	"operands":[
+	  {
+	    "@type":"korap:token",
+	    "wrap":{
+	      "@type":"korap:term",
+	      "foundry":"tt",
+	      "layer" : "pos",
+	      "key" : "ADJA",
+	      "match":"match:eq"
+	    }
+	  },
+	  {
+	    "@type":"korap:token",
+	    "wrap":{
+	      "@type":"korap:term",
+	      "foundry":"mate",
+		"layer" : "p",
+	      "key" : "NN",
+	      "match":"match:eq"
+	    }
+	  }
+	]
+      }
+    ]
+  },
+  "meta":[{"@type":"korap:meta-filter","@value":{"@type":"korap:term","@field":"korap:field#corpusID","@value":"WPD"}}],"startPage":1,"count":50,"context":{"left":["token",6],"right":["token",6]}}
diff --git a/src/test/resources/queries/bsp-context-2.jsonld b/src/test/resources/queries/bsp-context-2.jsonld
new file mode 100644
index 0000000..576d2f6
--- /dev/null
+++ b/src/test/resources/queries/bsp-context-2.jsonld
@@ -0,0 +1,24 @@
+{"@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+ "query":{
+   "@type":"korap:token",
+   "wrap":{
+     "@type":"korap:term",
+     "foundry" : "mate",
+     "layer":"l",
+     "key":"wert",
+     "match":"match:eq"
+   }
+ },
+ "meta":[
+   {
+     "@type":"korap:meta-filter",
+     "@value":{
+       "@type":"korap:term",
+       "@field":"korap:field#corpusID",
+       "@value":"WPD"
+     }
+   }
+ ],
+ "startPage":1,
+ "count":25,
+ "context":{"left":["char",210],"right":["char",210]},"cutOff":true}
diff --git a/src/test/resources/queries/bsp-context.jsonld b/src/test/resources/queries/bsp-context.jsonld
new file mode 100644
index 0000000..327b8be
--- /dev/null
+++ b/src/test/resources/queries/bsp-context.jsonld
@@ -0,0 +1,17 @@
+{
+  "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "query": {
+    "@type": "korap:token", 
+    "wrap": {
+      "@type": "korap:term", 
+      "foundry": "mate",
+      "layer" : "l",
+      "key" : "alphabet", 
+      "match": "match:eq"
+    }
+  },
+  "context":{
+    "left":["char",90],
+    "right":["char",90]
+  }
+}
diff --git a/src/test/resources/queries/bsp-cutoff.jsonld b/src/test/resources/queries/bsp-cutoff.jsonld
new file mode 100644
index 0000000..fea64b8
--- /dev/null
+++ b/src/test/resources/queries/bsp-cutoff.jsonld
@@ -0,0 +1,20 @@
+{
+  "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "query": {
+    "@type": "korap:token", 
+    "wrap": {
+      "@type": "korap:term", 
+      "foundry": "mate",
+      "layer": "lemma",
+      "key" : "alphabet", 
+      "match": "match:eq"
+    }
+  },
+  "startPage":2,
+  "count": 2,
+  "cutOff": true,
+  "context":{
+    "left":["char",90],
+    "right":["char",90]
+  }
+}
diff --git a/src/test/resources/queries/bsp-fail1.json b/src/test/resources/queries/bsp-fail1.json
index 16c16a0..a3e9bb3 100644
--- a/src/test/resources/queries/bsp-fail1.json
+++ b/src/test/resources/queries/bsp-fail1.json
@@ -1,25 +1,9 @@
 {
-    "@context": {
-        "@language": "de", 
-        "class": {
-            "@id": "korap:class", 
-            "@type": "xsd:integer"
-        }, 
-        "filter": "korap:filter", 
-        "korap": "http://korap.ids-mannheim.de/ns/query", 
-        "meta": "korap:meta", 
-        "operands": {
-            "@container": "@list", 
-            "@id": "korap:operands"
-        }, 
-        "query": "korap:query", 
-        "relation": {
-            "@id": "korap:relation", 
-            "@type": "korap:relation#types"
-        }
-    }, 
+  "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
     "query": {
         "@type": "korap:group", 
+        "frame": "frame:contains", 
+        "operation": "operation:position"
         "operands": [
             {
                 "@type": "korap:element", 
@@ -34,8 +18,6 @@
                 }
             }
         ], 
-        "position": "within", 
-        "relation": "position"
     },
     "startIndex": -2
 }
diff --git a/src/test/resources/queries/bsp-fail1.jsonld b/src/test/resources/queries/bsp-fail1.jsonld
new file mode 100644
index 0000000..d39a792
--- /dev/null
+++ b/src/test/resources/queries/bsp-fail1.jsonld
@@ -0,0 +1,25 @@
+{
+  "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+    "query": {
+        "@type": "korap:group", 
+        "frame": "frame:contains", 
+        "operation": "operation:position"
+        "operands": [
+            {
+              "@type": "korap:span", 
+              "key": "np"
+            }, 
+            {
+                "@type": "korap:token", 
+                "wrap": {
+                  "@type": "korap:term", 
+		  "foundry" : "mate",
+                  "layer": "l",
+		  "key" : "Mann", 
+                  "match": "match:eq"
+                }
+            }
+        ], 
+    },
+    "startIndex": -2
+}
diff --git a/src/test/resources/queries/bsp-fail2.jsonld b/src/test/resources/queries/bsp-fail2.jsonld
new file mode 100644
index 0000000..417083e
--- /dev/null
+++ b/src/test/resources/queries/bsp-fail2.jsonld
@@ -0,0 +1,28 @@
+{
+  "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "query": {
+    "@type": "korap:group", 
+    "operation": "operation:position",
+    "frame": "frame:contains", 
+    "operands": [
+      {
+        "@type": "korap:span", 
+	"foundry" : "cnx",
+	"layer" : "c",
+        "key": "np"
+      }, 
+      {
+        "@type": "korap:token", 
+        "wrap": {
+          "@type": "korap:term", 
+	  "foundry" : "mate",
+          "layer": "l",
+	  "key" : "Mann", 
+          "match": "match:eq"
+        }
+      }
+    ]
+  },
+  "count": 100,
+  "startPage": 1000
+}
diff --git a/src/test/resources/queries/bsp-paging.jsonld b/src/test/resources/queries/bsp-paging.jsonld
new file mode 100644
index 0000000..b410ea2
--- /dev/null
+++ b/src/test/resources/queries/bsp-paging.jsonld
@@ -0,0 +1,19 @@
+{
+  "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "query": {
+    "@type": "korap:token", 
+    "wrap": {
+      "@type": "korap:term", 
+      "foundry": "mate",
+      "layer" : "lemma",
+      "key":"alphabet", 
+      "match": "match:eq"
+    }
+  },
+  "startPage":2,
+  "count": 5,
+  "context":{
+    "left":["char",90],
+    "right":["char",90]
+  }
+}
diff --git a/src/test/resources/queries/bsp1.jsonld b/src/test/resources/queries/bsp1.jsonld
index 100d9fa..36fb042 100644
--- a/src/test/resources/queries/bsp1.jsonld
+++ b/src/test/resources/queries/bsp1.jsonld
@@ -114,7 +114,7 @@
       }, 
       {
         "@type": "korap:group", 
-        "quantifier": "*", 
+	"min" : 0,
         "operation": "operation:repetition",
         "operands": [
           {
@@ -132,7 +132,7 @@
               {
                 "@type": "korap:token", 
                 "wrap": {
-                  "@type": "korap:term", 
+                  "@type": "korap:term",
                   "layer": "base",
                   "key" : "bar"
                 }
diff --git a/src/test/resources/queries/bsp10.jsonld b/src/test/resources/queries/bsp10.jsonld
index 19ad4a2..643edc3 100644
--- a/src/test/resources/queries/bsp10.jsonld
+++ b/src/test/resources/queries/bsp10.jsonld
@@ -108,7 +108,8 @@
         "@type": "korap:token", 
         "wrap": {
           "@type": "korap:term", 
-          "layer": "base",
+	  "foundry" : "mate",
+          "layer": "lemma",
           "key" : "Katze"
         }
       }, 
diff --git a/src/test/resources/queries/bsp12.jsonld b/src/test/resources/queries/bsp12.jsonld
index b909da1..4db4b95 100644
--- a/src/test/resources/queries/bsp12.jsonld
+++ b/src/test/resources/queries/bsp12.jsonld
@@ -113,7 +113,8 @@
         "@type": "korap:token",
         "wrap" : {
           "@type": "korap:term", 
-          "layer": "base",
+          "foundry": "mate",
+          "layer": "lemma",
           "key" : "Mann"
         }
       }
diff --git a/src/test/resources/queries/bsp13b.jsonld b/src/test/resources/queries/bsp13b.jsonld
index f67adef..6a4b19e 100644
--- a/src/test/resources/queries/bsp13b.jsonld
+++ b/src/test/resources/queries/bsp13b.jsonld
@@ -113,9 +113,10 @@
         "@type": "korap:token", 
         "wrap": {
           "@type": "korap:term", 
+	  "foundry" : "mate",
           "layer": "pos",
           "key" : "Det", 
-	      "match" : "match:ne"
+	  "match" : "match:eq"
         }
       }
     ]
diff --git a/src/test/resources/queries/bsp14.jsonld b/src/test/resources/queries/bsp14.jsonld
index ad6e7e3..f9c98e0 100644
--- a/src/test/resources/queries/bsp14.jsonld
+++ b/src/test/resources/queries/bsp14.jsonld
@@ -104,7 +104,8 @@
     "@type": "korap:token", 
     "wrap": {
       "@type" : "korap:term",
-      "type": "type:regex", 
+      "type": "type:regex",
+      "layer": "orth",
       "key": "vers{2,3}uch"
     }
   }
diff --git a/src/test/resources/queries/bsp16.jsonld b/src/test/resources/queries/bsp16.jsonld
index 778a01b..72586cb 100644
--- a/src/test/resources/queries/bsp16.jsonld
+++ b/src/test/resources/queries/bsp16.jsonld
@@ -112,12 +112,14 @@
           "operands": [
             {
               "@type": "korap:term", 
-              "layer": "base",
+	      "foundry": "mate",
+              "layer": "lemma",
               "key" : "bar"
             }, 
             {
               "@type": "korap:term", 
-              "layer": "base",
+	      "foundry": "mate",
+              "layer": "lemma",
               "key" : "foo"
             }
           ]
diff --git a/src/test/resources/queries/bsp17.jsonld b/src/test/resources/queries/bsp17.jsonld
index 5fe54e0..2df7268 100644
--- a/src/test/resources/queries/bsp17.jsonld
+++ b/src/test/resources/queries/bsp17.jsonld
@@ -113,7 +113,8 @@
         "@type": "korap:token", 
         "wrap": {
           "@type": "korap:term", 
-          "layer": "base",
+	  "foundry" : "mate",
+          "layer": "lemma",
           "key" : "Mann"
         }
       }
diff --git a/src/test/resources/queries/bsp1b.jsonld b/src/test/resources/queries/bsp1b.jsonld
new file mode 100644
index 0000000..2a2631c
--- /dev/null
+++ b/src/test/resources/queries/bsp1b.jsonld
@@ -0,0 +1,64 @@
+{
+    "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+   "query":{
+      "@type":"korap:group",
+      "operation":"operation:or",
+      "operands":[
+         {
+            "@type":"korap:token",
+            "wrap":{
+               "@type":"korap:term",
+               "foundry":"mate",
+	      "layer" : "lemma",
+	      "key" :"foo",
+               "match":"match:eq"
+            }
+         },
+         {
+            "@type":"korap:group",
+           "operation":"operation:sequence",
+            "operands":[
+               {
+                  "@type":"korap:token",
+                  "wrap":{
+                     "@type":"korap:term",
+		    "foundry" : "mate",
+                     "layer":"lemma",
+		    "key":"foo",
+                     "match":"match:eq"
+                  }
+               },
+               {
+                  "@type":"korap:token",
+                  "wrap":{
+                     "@type":"korap:term",
+		    "foundry": "mate",
+                     "layer":"lemma",
+		    "key" : "bar",
+                     "match":"match:eq"
+                  }
+               }
+            ]
+         }
+      ]
+   },
+   "meta":{
+      "@type":"korap:meta",
+      "@value":{
+         "@type":"korap:group",
+         "operands":[
+            {
+               "@type":"korap:term",
+               "@value":"author:Goethe",
+               "relation":"="
+            },
+            {
+               "@type":"korap:term",
+               "@value":"year:1815",
+               "relation":"="
+            }
+         ],
+         "relation":"and"
+      }
+   }
+}
diff --git a/src/test/resources/queries/bsp2.jsonld b/src/test/resources/queries/bsp2.jsonld
index aa8673e..08ac500 100644
--- a/src/test/resources/queries/bsp2.jsonld
+++ b/src/test/resources/queries/bsp2.jsonld
@@ -112,7 +112,8 @@
             "@type": "korap:token", 
             "wrap": {
               "@type": "korap:term", 
-              "layer": "base", 
+	      "foundry": "mate", 
+              "layer": "lemma", 
               "key" : "foo"
             }
           }, 
@@ -120,7 +121,8 @@
             "@type": "korap:token", 
             "wrap": {
               "@type": "korap:term", 
-              "layer": "base",
+	      "foundry": "mate", 
+              "layer": "lemma",
               "key" : "bar"
             }
           }
@@ -130,7 +132,8 @@
         "@type": "korap:token", 
         "wrap": {
           "@type": "korap:term", 
-          "layer": "base",
+	  "foundry": "mate", 
+          "layer": "lemma",
           "key" : "foobar"
         }
       }
diff --git a/src/test/resources/queries/bsp3.jsonld b/src/test/resources/queries/bsp3.jsonld
index 642d91f..1a40038 100644
--- a/src/test/resources/queries/bsp3.jsonld
+++ b/src/test/resources/queries/bsp3.jsonld
@@ -114,7 +114,8 @@
             "@type": "korap:token", 
             "wrap": {
               "@type": "korap:term", 
-              "layer": "base",
+	      "foundry" : "mate",
+              "layer": "lemma",
               "key" : "Mann"
             }
           }
diff --git a/src/test/resources/queries/bsp4.json b/src/test/resources/queries/bsp4.json
index c7ddb5b..138bdd4 100644
--- a/src/test/resources/queries/bsp4.json
+++ b/src/test/resources/queries/bsp4.json
@@ -26,7 +26,7 @@
                 "operands": [
                     {
                         "@type": "korap:group", 
-                        "class": "0", 
+                        "class": 0, 
                         "operands": [
                             {
                                 "@type": "korap:token", 
diff --git a/src/test/resources/queries/bsp4.jsonld b/src/test/resources/queries/bsp4.jsonld
index b64ef29..c5cc7db 100644
--- a/src/test/resources/queries/bsp4.jsonld
+++ b/src/test/resources/queries/bsp4.jsonld
@@ -111,13 +111,15 @@
         "operands": [
           {
             "@type": "korap:group", 
+	    "operation":"operation:class",
             "class": 0, 
             "operands": [
               {
                 "@type": "korap:token", 
                 "wrap": {
                   "@type": "korap:term", 
-                  "layer": "base",
+		  "foundry" : "mate",
+                  "layer": "lemma",
                   "key" : "foo"
                 }
               }
diff --git a/src/test/resources/queries/bsp5.jsonld b/src/test/resources/queries/bsp5.jsonld
index 1a12d6d..bebc438 100644
--- a/src/test/resources/queries/bsp5.jsonld
+++ b/src/test/resources/queries/bsp5.jsonld
@@ -106,25 +106,29 @@
     "classRef": [1],
     "operands": [
       {
-        "@type": "korap:sequence",
+        "@type": "korap:group",
+	"operation" : "operation:sequence",
         "operands": [
           {
             "@type": "korap:token", 
             "wrap": {
               "@type": "korap:term", 
-              "layer": "base",
+	      "foundry" : "mate",
+              "layer": "lemma",
               "key" : "Der"
             }
           }, 
           {
             "@type": "korap:group", 
+	    "operation" : "operation:class",
             "class": 1, 
             "operands": [
               {
                 "@type": "korap:token", 
                 "wrap": {
                   "@type": "korap:term", 
-                  "layer": "base",
+                  "foundry": "mate",
+                  "layer": "lemma",
                   "key" : "Mann"
                 }
               }
diff --git a/src/test/resources/queries/bsp6.jsonld b/src/test/resources/queries/bsp6.jsonld
index fc9fe84..64e8d17 100644
--- a/src/test/resources/queries/bsp6.jsonld
+++ b/src/test/resources/queries/bsp6.jsonld
@@ -104,7 +104,8 @@
     "@type": "korap:token", 
     "wrap": {
       "@type": "korap:term", 
-      "layer": "base",
+      "foundry" : "mate",
+      "layer": "lemma",
       "key" : "Katze"
     }
   }
diff --git a/src/test/resources/queries/bsp7.jsonld b/src/test/resources/queries/bsp7.jsonld
index 074d2d3..46ab329 100644
--- a/src/test/resources/queries/bsp7.jsonld
+++ b/src/test/resources/queries/bsp7.jsonld
@@ -104,7 +104,8 @@
     "@type": "korap:token", 
     "wrap" : {
       "@type": "korap:term", 
-      "layer": "base",
+      "foundry": "mate",
+      "layer": "lemma",
       "key": "Katze", 
       "match": "match:ne"
     }
diff --git a/src/test/resources/queries/bsp9.jsonld b/src/test/resources/queries/bsp9.jsonld
index 41e9cfb..52f10b9 100644
--- a/src/test/resources/queries/bsp9.jsonld
+++ b/src/test/resources/queries/bsp9.jsonld
@@ -108,7 +108,8 @@
       "operands": [
         {
           "@type": "korap:term", 
-          "layer": "base",
+          "foundry": "mate",
+          "layer": "lemma",
           "key" : "Katze"
         }, 
         {
diff --git a/src/test/resources/queries/metaquery3.jsonld b/src/test/resources/queries/metaquery3.jsonld
new file mode 100644
index 0000000..0f7f3dd
--- /dev/null
+++ b/src/test/resources/queries/metaquery3.jsonld
@@ -0,0 +1,51 @@
+{
+    "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+    "startPage" : 2,
+    "count" : 5,
+    "context" : {
+      "left" : [ "token", 3 ],
+      "right" : [ "char", 6 ]
+    },
+   "query":{
+      "@type":"korap:group",
+      "operation":"operation:or",
+      "operands":[
+         {
+            "@type":"korap:token",
+            "wrap":{
+               "@type":"korap:term",
+	        "foundry" : "mate",
+               "layer":"l",
+	       "key":"Vokal",
+               "match":"match:eq"
+            }
+         },
+         {
+            "@type":"korap:group",
+	   "operation" : "operation:sequence",
+            "operands":[
+               {
+                  "@type":"korap:token",
+                  "wrap":{
+                     "@type":"korap:term",
+		     "foundry" : "mate",
+                     "layer":"l",
+		     "key" : "der",
+                     "match":"match:eq"
+                  }
+               },
+               {
+                  "@type":"korap:token",
+                  "wrap":{
+                     "@type":"korap:term",
+                     "foundry":"mate",
+		      "layer" : "p",
+		      "key" : "ADJA",
+                     "match":"match:eq"
+                  }
+               }
+            ]
+         }
+      ]
+   }
+}
diff --git a/src/test/resources/queries/metaquery4.jsonld b/src/test/resources/queries/metaquery4.jsonld
new file mode 100644
index 0000000..7da685d
--- /dev/null
+++ b/src/test/resources/queries/metaquery4.jsonld
@@ -0,0 +1,40 @@
+{
+  "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "startPage" : 1,
+  "count" : 5,
+  "context" : {
+    "left" : [ "token", 3 ],
+    "right" : [ "char", 6 ]
+  },
+  "query":{
+    "@type":"korap:token",
+    "wrap":{
+      "@type":"korap:term",
+      "foundry":"mate",
+      "layer":"l",
+      "key":"lediglich",
+      "match":"match:eq"
+    }
+  },
+  "meta": [
+    {
+      "@type": "korap:meta-filter",
+      "@id": "korap-filter#id-1223232",
+      "@value": {
+        "@type": "korap:group",
+        "relation": "between",
+        "@field": "korap:field#pubDate",
+        "operands": [
+          {
+            "@type": "korap:date",
+            "@value": "2000-01-01"
+          },
+          {
+            "@type": "korap:date",
+            "@value": "2013-12-31"
+          }
+        ]
+      }
+    }
+  ]
+}
diff --git a/src/test/resources/queries/metaquery5.jsonld b/src/test/resources/queries/metaquery5.jsonld
new file mode 100644
index 0000000..497494e
--- /dev/null
+++ b/src/test/resources/queries/metaquery5.jsonld
@@ -0,0 +1,46 @@
+{
+  "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "startPage" : 1,
+  "count" : 5,
+  "context" : {
+    "left" : [ "token", 3 ],
+    "right" : [ "char", 6 ]
+  },
+  "query":{
+    "@type":"korap:token",
+    "wrap":{
+      "@type":"korap:term",
+      "foundry": "mate",
+      "layer":"l",
+      "key":"lediglich",
+      "match":"match:eq"
+    }
+  },
+  "meta": [
+    {
+      "@type": "korap:meta-filter",
+      "@id": "korap-filter#id-1223232",
+      "@value": {
+	"@type": "korap:group",
+	"relation": "and",
+	"operands": [
+	  {
+            "@type": "korap:group",
+            "relation": "between",
+            "@field": "korap:field#pubDate",
+            "operands": [
+              {
+		"@type": "korap:date",
+		"@value": "2000-01-01"
+              },
+              {
+		"@type": "korap:date",
+		"@value": "2013-12-31"
+              }
+            ]
+	  }
+	]
+      }
+    }
+  ]
+}
diff --git a/src/test/resources/queries/metaquery6.jsonld b/src/test/resources/queries/metaquery6.jsonld
new file mode 100644
index 0000000..5acb266
--- /dev/null
+++ b/src/test/resources/queries/metaquery6.jsonld
@@ -0,0 +1,45 @@
+{
+  "@context": "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "startPage" : 1,
+  "count" : 5,
+  "context" : {
+    "left" : [ "token", 3 ],
+    "right" : [ "char", 6 ]
+  },
+  "query":{
+    "@type":"korap:token",
+    "wrap":{
+      "@type":"korap:term",
+      "foundry":"mate",
+      "layer":"l",
+      "key":"lediglich"
+    }
+  },
+  "meta": [
+    {
+      "@type": "korap:meta-filter",
+      "@id": "korap-filter#id-1223232",
+      "@value": {
+	"@type": "korap:group",
+	"relation": "and",
+	"operands": [
+	  {
+            "@type": "korap:group",
+            "relation": "between",
+            "@field": "korap:field#pubDate",
+            "operands": [
+              {
+		"@type": "korap:date",
+		"@value": "2005-01-01"
+              },
+              {
+		"@type": "korap:date",
+		"@value": "2013-12-31"
+              }
+            ]
+	  }
+	]
+      }
+    }
+  ]
+}