Minor bugfix for serialized contexts
diff --git a/CHANGES b/CHANGES
index 23dfbf6..3c3b911 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+0.31.1 2014-05-21
+ - [bugfix] Minor bugfix for wrongly serialized contexts
+ in responses (diewald)
+
0.31.0 2014-05-20
- [feature] span contexts in JSON-LD are now supported
- [bugfix] Multiple bugfixes regarding span context
diff --git a/src/main/java/de/ids_mannheim/korap/index/SearchContext.java b/src/main/java/de/ids_mannheim/korap/index/SearchContext.java
index 3c72456..d32624c 100644
--- a/src/main/java/de/ids_mannheim/korap/index/SearchContext.java
+++ b/src/main/java/de/ids_mannheim/korap/index/SearchContext.java
@@ -132,7 +132,11 @@
};
};
- public ObjectNode toJSON () {
+ public JsonNode toJSON () {
+ if (this.isSpanDefined()) {
+ return new TextNode(this.spanContext);
+ };
+
ArrayNode leftContext = mapper.createArrayNode();
leftContext.add(this.left.isToken() ? "token" : "char");
leftContext.add(this.left.getLength());
diff --git a/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java b/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java
index d2511ec..215c82a 100644
--- a/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java
+++ b/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java
@@ -377,6 +377,7 @@
assertEquals(3, kr.getTotalResults());
assertEquals(0, kr.getStartIndex());
assertEquals(25, kr.getItemsPerPage());
+ assertFalse(kr.getContext().toJSON().toString().equals("\"s\""));
json = getString(getClass().getResource("/queries/bsp-context-sentence.jsonld").getFile());
@@ -388,6 +389,7 @@
assertEquals(kr.getMatch(2).getSnippetBrackets(),
"In einem Zahlensystem mit einer Basis größer als 10 steht A oder a häufig für den dezimalen [Wert] 10, siehe auch Hexadezimalsystem.");
+ assertEquals(kr.getContext().toJSON().toString(), "\"s\"");
};