当前位置: 首页>>代码示例>>Java>>正文


Java RuntimeJsonMappingException类代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.RuntimeJsonMappingException的典型用法代码示例。如果您正苦于以下问题:Java RuntimeJsonMappingException类的具体用法?Java RuntimeJsonMappingException怎么用?Java RuntimeJsonMappingException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RuntimeJsonMappingException类属于com.fasterxml.jackson.databind包,在下文中一共展示了RuntimeJsonMappingException类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNestedOrderedOrGetEmpty

import com.fasterxml.jackson.databind.RuntimeJsonMappingException; //导入依赖的package包/类
public Config getNestedOrderedOrGetEmpty(String key)
{
    JsonNode value = getNode(key);
    if (value == null) {
        value = newObjectNode();
    }
    else if (value.isArray()) {
        Config config = new Config(mapper);
        Iterator<JsonNode> ite = ((ArrayNode) value).elements();
        while (ite.hasNext()) {
            JsonNode nested = ite.next();
            if (!(nested instanceof ObjectNode)) {
                throw new RuntimeJsonMappingException("Expected object but got "+nested);
            }
            // here assumes config is an order-preserving map
            config.setAll(new Config(mapper, (ObjectNode) nested));
        }
        return config;
    }
    else if (!value.isObject()) {
        throw new ConfigException("Parameter '"+key+"' must be an object or array of objects");
    }
    return new Config(mapper, (ObjectNode) value);
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:25,代码来源:Config.java

示例2: decode

import com.fasterxml.jackson.databind.RuntimeJsonMappingException; //导入依赖的package包/类
@Override
public Object decode(Response response, Type type) throws IOException, FeignException {
    if (response.body() == null) {
        return null;
    }
    Reader reader = response.body().asReader();
    if (!reader.markSupported()) {
        reader = new BufferedReader(reader, 1);
    }
    try {
        // Read the first byte to see if we have any data
        reader.mark(1);
        if (reader.read() == -1) {
            return null; // Eagerly returning null avoids "No content to map due to end-of-input"
        }
        reader.reset();
        return mapper.readValue(reader, mapper.constructType(type));
    } catch (RuntimeJsonMappingException e) {
        Throwable cause = e.getCause();
        if (cause != null && cause instanceof IOException) {
            throw IOException.class.cast(cause);
        }
        throw e;
    }
}
 
开发者ID:wso2,项目名称:msf4j,代码行数:26,代码来源:MSF4JJacksonDecoder.java

示例3: read

import com.fasterxml.jackson.databind.RuntimeJsonMappingException; //导入依赖的package包/类
@Override
public Object read() throws IOException {
  if (closed) {
    throw new IOException("The parser is closed");
  }
  try {
    Object value = null;
    switch (mode) {
      case ARRAY_OBJECTS:
        value = readObjectFromArray();
        break;
      case MULTIPLE_OBJECTS:
        value = readObjectFromStream();
        break;
    }
    return value;
  } catch (RuntimeJsonMappingException ex) {
    throw new JsonParseException(ex.toString(), jsonParser.getTokenLocation(), ex);
  }
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:21,代码来源:JsonObjectReaderImpl.java

示例4: decode

import com.fasterxml.jackson.databind.RuntimeJsonMappingException; //导入依赖的package包/类
@Override
public Object decode(Response response, Type type) throws IOException {
  if (response.status() == 404) return Util.emptyValueOf(type);
  if (response.body() == null) return null;
  Reader reader = response.body().asReader();
  if (!reader.markSupported()) {
    reader = new BufferedReader(reader, 1);
  }
  try {
    // Read the first byte to see if we have any data
    reader.mark(1);
    if (reader.read() == -1) {
      return null; // Eagerly returning null avoids "No content to map due to end-of-input"
    }
    reader.reset();
    return mapper.readValue(reader, mapper.constructType(type));
  } catch (RuntimeJsonMappingException e) {
    if (e.getCause() != null && e.getCause() instanceof IOException) {
      throw IOException.class.cast(e.getCause());
    }
    throw e;
  }
}
 
开发者ID:OpenFeign,项目名称:feign,代码行数:24,代码来源:JacksonDecoder.java

示例5: decode

import com.fasterxml.jackson.databind.RuntimeJsonMappingException; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Object decode(final Response response, final Type type) throws IOException {
    if (
        response.status() == HttpURLConnection.HTTP_NO_CONTENT
            || response.body() == null
            || (response.body().length() != null && response.body().length() == 0)
        ) {
        return null;
    }

    try (final Reader reader = response.body().asReader()) {
        return this.mapper.readValue(reader, this.mapper.constructType(type));
    } catch (final JsonMappingException jme) {
        // The case where for whatever reason (most likely bad design) where the server returned OK and
        // trying to de-serialize the content had no content (e.g. the return status should have been no-content)
        if (response.status() == HttpURLConnection.HTTP_OK
            && jme.getMessage().startsWith(NO_CONTENT_MESSAGE)) {
            return null;
        }

        throw jme;
    } catch (final RuntimeJsonMappingException e) {
        if (e.getCause() != null && e.getCause() instanceof IOException) {
            throw IOException.class.cast(e.getCause());
        }
        throw e;
    }
}
 
开发者ID:Netflix,项目名称:metacat,代码行数:32,代码来源:JacksonDecoder.java

示例6: normalizeValidateObjectNode

import com.fasterxml.jackson.databind.RuntimeJsonMappingException; //导入依赖的package包/类
private ObjectNode normalizeValidateObjectNode(Object object)
    throws IOException
{
    JsonNode node = treeObjectMapper.readTree(treeObjectMapper.writeValueAsString(object));
    if (!node.isObject()) {
        throw new RuntimeJsonMappingException("Expected object to load Config but got "+node);
    }
    return (ObjectNode) node;
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:10,代码来源:YamlLoader.java

示例7: deserializeFromJackson

import com.fasterxml.jackson.databind.RuntimeJsonMappingException; //导入依赖的package包/类
@JsonCreator
public static Config deserializeFromJackson(@JacksonInject ObjectMapper mapper, JsonNode object)
{
    if (!object.isObject()) {
        throw new RuntimeJsonMappingException("Expected object but got "+object);
    }
    return new Config(mapper, (ObjectNode) object);
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:9,代码来源:Config.java

示例8: merge

import com.fasterxml.jackson.databind.RuntimeJsonMappingException; //导入依赖的package包/类
/**
 * Merges the current application configuration with the provided one.
 * 
 * @param config The configuration to retrieve values from.
 */
public void merge(Map<String, String> config) {
	String languageCode = getString(config, "language");
	Locale theLanguage;
	if (languageCode != null) {
		theLanguage = Locale.forLanguageTag(languageCode);
	} else {
		theLanguage = Locale.getDefault();
	}
	setLanguage(theLanguage);

	pageSizeForText = getInt(config, "paging.textPageSize");
	pageSizeForImages = getInt(config, "paging.imagePageSize");
	pageSizeForAlbums = getInt(config, "paging.albumPageSize");
	thumbnailWidth = getInt(config, "thumbnail.width");
	thumbnailHeight = getInt(config, "thumbnail.height");

	// Load the header links as JSON data
	headerLinksSpec = getString(config, "header.quickLinks", "[]");
	JsonFactory jsonFactory = new JsonFactory();
	ObjectMapper jsonMapper = new ObjectMapper(jsonFactory);
	CollectionType jsonType = jsonMapper.getTypeFactory().constructCollectionType(ArrayList.class,
			HeaderLink.class);
	List<HeaderLink> links = new ArrayList<>();
	try {
		LOGGER.debug("Header links: {}", headerLinksSpec);
		JsonParser jsonParser = jsonFactory.createParser(headerLinksSpec);
		links = jsonMapper.<List<HeaderLink>> readValue(jsonParser, jsonType);
	} catch (RuntimeJsonMappingException | IOException e) {
		LOGGER.warn("Failed to load the header configuration", e);
	}
	headerLinks = links;
}
 
开发者ID:The4thLaw,项目名称:demyo,代码行数:38,代码来源:ApplicationConfiguration.java


注:本文中的com.fasterxml.jackson.databind.RuntimeJsonMappingException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。