Package com.yahoo.tensor.serialization
Class JsonFormat
java.lang.Object
com.yahoo.tensor.serialization.JsonFormat
Writes tensors on the JSON format used in Vespa tensor document fields:
A JSON map containing a 'cells' or 'values' array.
See
https://docs.vespa.ai/en/reference/document-json-format.html
- Author:
- bratseth
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Tensordecode(TensorType type, byte[] jsonTensorValue) Deserializes the given tensor from JSON formatstatic double[]decodeHexString(String input, TensorType.Value valueType) static doubledecodeNumberString(String input) static byte[]Serializes the given tensor value into JSON format, in long format, wrapped in an object containing "cells" only.static byte[]Serializes the given tensor value into JSON format.static byte[]encode(Tensor tensor, JsonFormat.EncodeOptions options) Serializes the given tensor value into JSON format.static byte[]encodeShortForm(Tensor tensor) Deprecated.use #encode(#Tensor, boolean, boolean)static byte[]encodeWithType(Tensor tensor) Deprecated.use #encode(#Tensor, boolean, boolean)
-
Constructor Details
-
JsonFormat
public JsonFormat()
-
-
Method Details
-
encode
Serializes the given tensor value into JSON format.- Parameters:
tensor- the tensor to serializeshortForm- whether to encode in a short type-dependent formatdirectValues- whether to encode values directly, or wrapped in am object containing "type" and "cells"
-
encode
Serializes the given tensor value into JSON format.- Parameters:
tensor- the tensor to serializeoptions- format options for short/long, wrapped/direct, etc
-
encode
Serializes the given tensor value into JSON format, in long format, wrapped in an object containing "cells" only. -
encodeWithType
Deprecated.use #encode(#Tensor, boolean, boolean)Serializes the given tensor type and value into JSON format. -
encodeShortForm
Deprecated.use #encode(#Tensor, boolean, boolean)Serializes the given tensor type and value into a short-form JSON format. -
decode
Deserializes the given tensor from JSON format -
decodeHexString
-
decodeNumberString
-