public class JsonUtils
extends java.lang.Object
Row
.
This class provides utility methods to parse, validate and translate between JSON
Schema-formatted schemas and Beam Schemas. The support is based on the
everit-json-schema
package, which is not provided by default.
Therefore, functionality in JsonUtils::beamSchemaFromJsonSchema
requires that you
include everit-json-schema
in your project like so:
<dependency>
<groupId>com.github.erosb < /groupId>
<artifactId>everit-json-schema < /artifactId>
<version>${everit-json.version} < /version>
< /dependency>
Note: This functionality has been tested with everit-json-schema
version
1.14.1.
The current Beam implementation does not support all possible features of JSON-schema. The current implementation supports:
The following JSON-schema features are not supported:
contentMediaType
) are ignored.
Constructor and Description |
---|
JsonUtils() |
Modifier and Type | Method and Description |
---|---|
static Schema |
beamSchemaFromJsonSchema(java.lang.String jsonSchemaStr) |
static SimpleFunction<byte[],Row> |
getJsonBytesToRowFunction(Schema beamSchema)
Returns a
SimpleFunction mapping JSON byte[] arrays to Beam Row s. |
static SimpleFunction<java.lang.String,Row> |
getJsonStringToRowFunction(Schema beamSchema)
|
static SimpleFunction<Row,byte[]> |
getRowToJsonBytesFunction(Schema beamSchema)
Returns a
SimpleFunction mapping Beam Row s to JSON byte[] arrays. |
static SimpleFunction<Row,java.lang.String> |
getRowToJsonStringsFunction(Schema beamSchema)
|
static org.everit.json.schema.ObjectSchema |
jsonSchemaFromBeamSchema(Schema beamSchema) |
static java.lang.String |
jsonSchemaStringFromBeamSchema(Schema beamSchema) |
public static SimpleFunction<byte[],Row> getJsonBytesToRowFunction(Schema beamSchema)
SimpleFunction
mapping JSON byte[] arrays to Beam Row
s.public static SimpleFunction<java.lang.String,Row> getJsonStringToRowFunction(Schema beamSchema)
public static SimpleFunction<Row,byte[]> getRowToJsonBytesFunction(Schema beamSchema)
SimpleFunction
mapping Beam Row
s to JSON byte[] arrays.public static SimpleFunction<Row,java.lang.String> getRowToJsonStringsFunction(Schema beamSchema)
public static java.lang.String jsonSchemaStringFromBeamSchema(Schema beamSchema)
public static org.everit.json.schema.ObjectSchema jsonSchemaFromBeamSchema(Schema beamSchema)
public static Schema beamSchemaFromJsonSchema(java.lang.String jsonSchemaStr)