Tabnine Logo
FromJson
Code IndexAdd Tabnine to your IDE (free)

How to use
FromJson
in
com.moz.fiji.schema.util

Best Java code snippets using com.moz.fiji.schema.util.FromJson (Showing top 7 results out of 315)

origin: com.moz.fiji.mapreduce.lib/fiji-mapreduce-lib

/**
 * Reads a table import mapping descriptor from its JSON serialized form.
 *
 * @param json JSON string.
 * @return the decoded table layout descriptor.
 * @throws IOException on I/O error.
 */
public static TableImportDescriptorDesc readTableImportDescriptorDescFromJSON(String json)
  throws IOException {
 final TableImportDescriptorDesc desc =
   (TableImportDescriptorDesc) FromJson.fromJsonString(json,
     TableImportDescriptorDesc.SCHEMA$);
 return desc;
}
origin: com.moz.fiji.schema/fiji-schema

 while (it.hasNext()) {
  final JsonNode element = it.next();
  list.add(fromJsonNode(element, schema.getElementType()));
 while (it.hasNext()) {
  final Map.Entry<String, JsonNode> entry = it.next();
  map.put(entry.getKey(), fromJsonNode(entry.getValue(), schema.getValueType()));
 final SpecificRecord record = newSpecificRecord(schema.getFullName());
 for (Schema.Field field : schema.getFields()) {
  final String fieldName = field.name();
  final JsonNode fieldElement = json.get(fieldName);
  if (fieldElement != null) {
   final Object fieldValue = fromJsonNode(fieldElement, field.schema());
   record.put(field.pos(), fieldValue);
  } else if (field.defaultValue() != null) {
   record.put(field.pos(), fromJsonNode(field.defaultValue(), field.schema()));
  } else {
   throw new IOException(String.format(
case UNION: return fromUnionJsonNode(json, schema);
 return enumValue(schema.getFullName(), enumValStr);
origin: com.moz.fiji.schema/fiji-schema

final Schema optionalType = AvroUtils.getOptionalType(schema);
if (optionalType != null) {
 return json.isNull() ? null : fromJsonNode(json, optionalType);
  return fromJsonNode(actualNode, type);
 return fromJsonNode(json, type);
} catch (IOException ioe) {
origin: com.moz.fiji.schema/fiji-schema

public FijiRowFilter createFromJson(JsonNode root) {
 try {
  final RowKeyFormat2 rowKeyFormat = (RowKeyFormat2) FromJson.fromAvroJsonString(
    root.path(ROW_KEY_FORMAT_NODE).getTextValue(), RowKeyFormat2.SCHEMA$);
  final JsonNode componentsJsonNode = root.path(COMPONENTS_NODE);
origin: com.moz.fiji.schema/fiji-schema

/**
 * Decodes a JSON encoded record.
 *
 * @param json JSON tree to decode, encoded as a string.
 * @param schema Avro schema of the value to decode.
 * @return the decoded value.
 * @throws IOException on error.
 */
public static Object fromJsonString(String json, Schema schema) throws IOException {
 final ObjectMapper mapper = new ObjectMapper();
 final JsonParser parser = new JsonFactory().createJsonParser(json)
   .enable(Feature.ALLOW_COMMENTS)
   .enable(Feature.ALLOW_SINGLE_QUOTES)
   .enable(Feature.ALLOW_UNQUOTED_FIELD_NAMES);
 final JsonNode root = mapper.readTree(parser);
 return fromJsonNode(root, schema);
}
origin: com.moz.fiji.schema/fiji-schema

 /** {@inheritDoc} */
 @Override
 public FijiRowFilter createFromJson(JsonNode root) {
  final String family = root.path(FAMILY_NODE).getTextValue();
  final String qualifier = root.path(QUALIFIER_NODE).getTextValue();
  final String schema = root.path(VALUE_NODE).path(SCHEMA_NODE).getTextValue();
  final Schema writerSchema = (new Schema.Parser()).parse(schema);
  final String data = root.path(VALUE_NODE).path(DATA_NODE).getTextValue();
  try {
   final DecodedCell<?> cell = new DecodedCell<Object>(writerSchema,
     FromJson.fromAvroJsonString(data, writerSchema));
   return new ColumnValueEqualsRowFilter(family, qualifier, cell);
  } catch (IOException ioe) {
   throw new FijiIOException(ioe);
  }
 }
}
origin: com.moz.fiji.schema/fiji-schema

/**
 * Reads a table layout descriptor from its JSON serialized form.
 *
 * @param istream JSON input stream.
 * @return the decoded table layout descriptor.
 * @throws IOException on I/O error.
 */
public static TableLayoutDesc readTableLayoutDescFromJSON(InputStream istream)
  throws IOException {
 final String json = IOUtils.toString(istream);
 final TableLayoutDesc desc =
   (TableLayoutDesc) FromJson.fromJsonString(json, TableLayoutDesc.SCHEMA$);
 return desc;
}
com.moz.fiji.schema.utilFromJson

Javadoc

Decode a JSON string into an Avro record.

Most used methods

  • fromJsonString
    Decodes a JSON encoded record.
  • enumValue
    Looks up an Avro enum by name and string value.
  • fromAvroJsonString
    Standard Avro JSON decoder.
  • fromJsonNode
    Decodes a JSON node as an Avro value. Comply with specified default values when decoding records wit
  • fromUnionJsonNode
    Decodes a union from a JSON node.
  • newSpecificRecord
    Instantiates a specific record by name.

Popular in Java

  • Updating database using SQL prepared statement
  • onRequestPermissionsResult (Fragment)
  • runOnUiThread (Activity)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • Runner (org.openjdk.jmh.runner)
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now