summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/pom.xml5
-rw-r--r--client/src/main/java/ai/vespa/client/dsl/Annotation.java2
-rw-r--r--client/src/main/java/ai/vespa/client/dsl/DotProduct.java2
-rw-r--r--client/src/main/java/ai/vespa/client/dsl/Q.java13
-rw-r--r--client/src/main/java/ai/vespa/client/dsl/Wand.java3
-rw-r--r--client/src/main/java/ai/vespa/client/dsl/WeightedSet.java2
6 files changed, 18 insertions, 9 deletions
diff --git a/client/pom.xml b/client/pom.xml
index 1da3cbc68c5..9d643d63cf8 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -18,9 +18,8 @@
<dependencies>
<dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- <version>${gson.version}</version>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
diff --git a/client/src/main/java/ai/vespa/client/dsl/Annotation.java b/client/src/main/java/ai/vespa/client/dsl/Annotation.java
index ae95ed8647c..66887365d73 100644
--- a/client/src/main/java/ai/vespa/client/dsl/Annotation.java
+++ b/client/src/main/java/ai/vespa/client/dsl/Annotation.java
@@ -31,7 +31,7 @@ public class Annotation {
@Override
public String toString() {
- return annotations == null || annotations.isEmpty() ? "" : Q.gson.toJson(annotations);
+ return annotations == null || annotations.isEmpty() ? "" : Q.toJson(annotations);
}
}
diff --git a/client/src/main/java/ai/vespa/client/dsl/DotProduct.java b/client/src/main/java/ai/vespa/client/dsl/DotProduct.java
index 0132c4cd4da..4e696a0b825 100644
--- a/client/src/main/java/ai/vespa/client/dsl/DotProduct.java
+++ b/client/src/main/java/ai/vespa/client/dsl/DotProduct.java
@@ -21,7 +21,7 @@ public class DotProduct extends QueryChain {
@Override
public String toString() {
- return "dotProduct(" + fieldName + ", " + Q.gson.toJson(weightedSet) + ")";
+ return "dotProduct(" + fieldName + ", " + Q.toJson(weightedSet) + ")";
}
@Override
diff --git a/client/src/main/java/ai/vespa/client/dsl/Q.java b/client/src/main/java/ai/vespa/client/dsl/Q.java
index cfc0121c3f3..70e0e644c07 100644
--- a/client/src/main/java/ai/vespa/client/dsl/Q.java
+++ b/client/src/main/java/ai/vespa/client/dsl/Q.java
@@ -1,7 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package ai.vespa.client.dsl;
-import com.google.gson.Gson;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.List;
import java.util.Map;
@@ -12,7 +13,15 @@ import java.util.Map;
*/
public final class Q {
- static Gson gson = new Gson();
+ private static final ObjectMapper mapper = new ObjectMapper();
+ static String toJson(Object o) {
+ try {
+ return mapper.writeValueAsString(o);
+ }
+ catch (JsonProcessingException e) {
+ throw new RuntimeException(e);
+ }
+ }
private static Sources SELECT_ALL_FROM_SOURCES_ALL = new Sources(new Select("*"), "*");
public static Select select(String fieldName) { return new Select(fieldName);
diff --git a/client/src/main/java/ai/vespa/client/dsl/Wand.java b/client/src/main/java/ai/vespa/client/dsl/Wand.java
index bda5e2d9802..56bf3e3cf1d 100644
--- a/client/src/main/java/ai/vespa/client/dsl/Wand.java
+++ b/client/src/main/java/ai/vespa/client/dsl/Wand.java
@@ -65,7 +65,8 @@ public class Wand extends QueryChain {
@Override
public String toString() {
boolean hasAnnotation = A.hasAnnotation(annotation);
- String s = Text.format("wand(%s, %s)", fieldName, Q.gson.toJson(value));
+ String s = Text.format("wand(%s, %s)", fieldName, Q.toJson(value));
return hasAnnotation ? Text.format("([%s]%s)", annotation, s) : s;
}
+
}
diff --git a/client/src/main/java/ai/vespa/client/dsl/WeightedSet.java b/client/src/main/java/ai/vespa/client/dsl/WeightedSet.java
index e4162003451..c497abd4965 100644
--- a/client/src/main/java/ai/vespa/client/dsl/WeightedSet.java
+++ b/client/src/main/java/ai/vespa/client/dsl/WeightedSet.java
@@ -21,7 +21,7 @@ public class WeightedSet extends QueryChain {
@Override
public String toString() {
- return "weightedSet(" + fieldName + ", " + Q.gson.toJson(weightedSet) + ")";
+ return "weightedSet(" + fieldName + ", " + Q.toJson(weightedSet) + ")";
}
@Override