aboutsummaryrefslogtreecommitdiffstats
path: root/client/src
diff options
context:
space:
mode:
authorjonmv <venstad@gmail.com>2022-10-21 13:25:37 +0200
committerjonmv <venstad@gmail.com>2022-10-21 13:25:37 +0200
commit56e1715bb9d40ed751c4e377a3d1ee47aab84380 (patch)
tree1a2884b0a27cffb75b6db4f5094845fc4cae419f /client/src
parente7aa4c8a7ff622d9f5d7fbc0a6af6dd06e751dbc (diff)
Replace gson with jackson in client module
Diffstat (limited to 'client/src')
-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
5 files changed, 16 insertions, 6 deletions
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