org.codehaus.jackson.JsonNode.isNull()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(255)

本文整理了Java中org.codehaus.jackson.JsonNode.isNull()方法的一些代码示例,展示了JsonNode.isNull()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonNode.isNull()方法的具体详情如下:
包路径:org.codehaus.jackson.JsonNode
类名称:JsonNode
方法名:isNull

JsonNode.isNull介绍

[英]Method that can be used to check if this node was created from Json liternal null value.
[中]方法,该方法可用于检查此节点是否是根据Json liternal空值创建的。

代码示例

代码示例来源:origin: brianfrankcooper/YCSB

protected static void fromJson(
  String value, Set<String> fields,
  Map<String, ByteIterator> result) throws IOException {
 JsonNode json = MAPPER.readTree(value);
 boolean checkFields = fields != null && !fields.isEmpty();
 for (Iterator<Map.Entry<String, JsonNode>> jsonFields = json.getFields();
    jsonFields.hasNext();
    /* increment in loop body */) {
  Map.Entry<String, JsonNode> jsonField = jsonFields.next();
  String name = jsonField.getKey();
  if (checkFields && !fields.contains(name)) {
   continue;
  }
  JsonNode jsonValue = jsonField.getValue();
  if (jsonValue != null && !jsonValue.isNull()) {
   result.put(name, new StringByteIterator(jsonValue.asText()));
  }
 }
}

代码示例来源:origin: org.apache.avro/avro

throw new AvroRuntimeException("Field " + field
                 + " not set and has no default value");
if (json.isNull()
  && (field.schema().getType() == Type.NULL
    || (field.schema().getType() == Type.UNION

代码示例来源:origin: kaaproject/kaa

if (byDefault != null && !byDefault.isNull()) {
 return applyDefaultValue(schemaNode, byDefault);

代码示例来源:origin: apache/nifi

if (!fieldNode.isNull()) {
  String fieldValue = createSqlStringValue(fieldNode, colSize, sqlType);
  attributes.put(attributePrefix + ".args." + fieldCount + ".value", fieldValue);

代码示例来源:origin: apache/nifi

if (!fieldNode.isNull()) {
  String fieldValue = fieldNode.asText();
  if (colSize != null && fieldValue.length() > colSize) {

代码示例来源:origin: apache/nifi

if (!fieldNode.isNull()) {
  String fieldValue = createSqlStringValue(fieldNode, colSize, sqlType);
  attributes.put(attributePrefix + ".args." + fieldCount + ".value", fieldValue);

代码示例来源:origin: neo4j/neo4j

if ( !node.isNull() )

代码示例来源:origin: org.apache.avro/avro

return defaultValue.isBoolean();
case NULL:
 return defaultValue.isNull();
case ARRAY:
 if (!defaultValue.isArray())

代码示例来源:origin: org.apache.avro/avro

} else if (jsonNode.isNull()) {
 return JsonProperties.NULL_VALUE;
} else if (jsonNode.isBoolean()) {

代码示例来源:origin: apache/hive

@Test
public void testJsonEmptyRPFormatter() throws Exception {
 WMFullResourcePlan fullRp = createRP("test_rp_1", null, null);
 formatter.showFullResourcePlan(out, fullRp);
 out.flush();
 ObjectMapper objectMapper = new ObjectMapper();
 JsonNode jsonTree = objectMapper.readTree(bos.toByteArray());
 assertNotNull(jsonTree);
 assertTrue(jsonTree.isObject());
 assertEquals("test_rp_1", jsonTree.get("name").asText());
 assertTrue(jsonTree.get("parallelism").isNull());
 assertTrue(jsonTree.get("defaultPool").isNull());
 assertTrue(jsonTree.get("pools").isArray());
 assertEquals(0, jsonTree.get("pools").size());
}

代码示例来源:origin: apache/nifi

protected Object convertField(final JsonNode fieldNode, final String fieldName, final DataType desiredType, final boolean dropUnknown) throws IOException, MalformedRecordException {
  if (fieldNode == null || fieldNode.isNull()) {
    return null;

代码示例来源:origin: apache/nifi

protected Object convertField(final JsonNode fieldNode, final String fieldName, final DataType desiredType, final boolean dropUnknown) throws IOException, MalformedRecordException {
  if (fieldNode == null || fieldNode.isNull()) {
    return null;

代码示例来源:origin: apache/nifi

protected Object getRawNodeValue(final JsonNode fieldNode, final DataType dataType) throws IOException {
  if (fieldNode == null || fieldNode.isNull()) {
    return null;

代码示例来源:origin: voldemort/voldemort

switch(fieldType) {
  case NULL:
    if(!defaultJson.isNull()) {
      expectedVal = "null";

代码示例来源:origin: apache/nifi

protected Object getRawNodeValue(final JsonNode fieldNode, final DataType dataType) throws IOException {
  if (fieldNode == null || fieldNode.isNull()) {
    return null;

代码示例来源:origin: neo4j/neo4j

private static void assertJsonEquals( String message, Object expected, JsonNode actual )
{
  if ( expected == null )
  {
    assertTrue( message, actual == null || actual.isNull() );
  }
  else if ( expected instanceof String )
  {
    assertEquals( message, expected, actual.getTextValue() );
  }
  else if ( expected instanceof Number )
  {
    assertEquals( message, expected, actual.getNumberValue() );
  }
  else
  {
    fail( message + " - unexpected type - " + expected );
  }
}

代码示例来源:origin: org.apache.avro/avro

break;
case NULL:
 if (!n.isNull())
  throw new AvroTypeException("Non-null default value for null type: "+n);
 e.writeNull();

代码示例来源:origin: klout/brickhouse

@Override
public Object parseJson(JsonNode jsonNode) {
  /// For structs, they just return a list of object values
  if (jsonNode.isNull())
    return null;
  List<Object> valList = new ArrayList<Object>();
  for (int i = 0; i < fieldNames.size(); ++i) {
    String key = fieldNames.get(i);
    JsonNode valNode = jsonNode.get(key);
    InspectorHandle valHandle = handleList.get(i);
    Object valObj = valHandle.parseJson(valNode);
    valList.add(valObj);
  }
  return valList;
}

代码示例来源:origin: klout/brickhouse

@Override
public Object parseJson(JsonNode jsonNode) {
  if (jsonNode.isNull())
    return null;
  Map<String, Object> newMap = (Map<String, Object>) retInspector.create();
  Iterator<String> keys = jsonNode.getFieldNames();
  while (keys.hasNext()) {
    String key = keys.next();
    JsonNode valNode = jsonNode.get(key);
    Object val = mapValHandle.parseJson(valNode);
    newMap.put(key, val);
  }
  return newMap;
}

代码示例来源:origin: klout/brickhouse

@Override
public Object parseJson(JsonNode jsonNode) {
  if (jsonNode.isNull())
    return null;
  List newList = (List) retInspector.create(0);
  Iterator<JsonNode> listNodes = jsonNode.getElements();
  while (listNodes.hasNext()) {
    JsonNode elemNode = listNodes.next();
    if (elemNode != null) {
      Object elemObj = elemHandle.parseJson(elemNode);
      newList.add(elemObj);
    } else {
      newList.add(null);
    }
  }
  return newList;
}

相关文章