diff options
author | Lester Solbakken <lesters@yahoo-inc.com> | 2017-11-09 11:00:24 +0100 |
---|---|---|
committer | Lester Solbakken <lesters@yahoo-inc.com> | 2017-11-09 11:00:24 +0100 |
commit | a33e005517b15dc9eb09aed0bc7ccd98e27515dd (patch) | |
tree | fe8916e2e8befca1fc0dda3cf2f016be02735108 /vespajlib/src | |
parent | acfd85267604ba5c84656e74149f944ccdea667e (diff) |
Correct use of asText instead of toString in JSON
Diffstat (limited to 'vespajlib/src')
-rw-r--r-- | vespajlib/src/test/java/com/yahoo/tensor/serialization/SerializationTestCase.java | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/vespajlib/src/test/java/com/yahoo/tensor/serialization/SerializationTestCase.java b/vespajlib/src/test/java/com/yahoo/tensor/serialization/SerializationTestCase.java index a1ef30ffe52..68bf59e3ed9 100644 --- a/vespajlib/src/test/java/com/yahoo/tensor/serialization/SerializationTestCase.java +++ b/vespajlib/src/test/java/com/yahoo/tensor/serialization/SerializationTestCase.java @@ -58,7 +58,7 @@ public class SerializationTestCase { JsonNode binaryNode = node.get("binary"); for (int i = 0; i < binaryNode.size(); ++i) { - byte[] bin = getBytes(binaryNode.get(i).toString()); + byte[] bin = getBytes(binaryNode.get(i).asText()); Tensor decodedTensor = TypedBinaryFormat.decode(Optional.empty(), GrowableByteBuffer.wrap(bin)); if (spec.equalsIgnoreCase("double")) { @@ -92,7 +92,7 @@ public class SerializationTestCase { } private String getSpec(JsonNode tensor) { - return removeQuote(tensor.get("type").toString()); + return tensor.get("type").asText(); } private void tensorCells(JsonNode tensor, Tensor.Builder builder) { @@ -116,12 +116,12 @@ public class SerializationTestCase { while (dimension.hasNext()) { String name = dimension.next(); JsonNode label = address.get(name); - cellBuilder.label(removeQuote(name), removeQuote(label.toString())); + cellBuilder.label(name, label.asText()); } } private byte[] getBytes(String binaryRepresentation) { - return parseHexValue(binaryRepresentation.substring(3, binaryRepresentation.length() - 1)); + return parseHexValue(binaryRepresentation.substring(2)); } private byte[] parseHexValue(String s) { @@ -146,12 +146,4 @@ public class SerializationTestCase { throw new IllegalArgumentException("Hex contains illegal characters"); } - private String removeQuote(String s) { - if (!s.startsWith("\"")) { - return s; - } - return s.substring(1, s.length()-1); - } - - } |