List of usage examples for com.fasterxml.jackson.module.mrbean MrBeanModule MrBeanModule
public MrBeanModule()
From source file:cc.arduino.contributions.libraries.LibrariesIndexer.java
private void parseIndex(File file) throws IOException { InputStream indexIn = null;//from w w w.j a v a 2 s.co m try { indexIn = new FileInputStream(file); ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new MrBeanModule()); mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); mapper.configure(DeserializationFeature.EAGER_DESERIALIZER_FETCH, true); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); LibrariesIndex newIndex = mapper.readValue(indexIn, LibrariesIndex.class); newIndex.getLibraries().stream() .filter(library -> library.getCategory() == null || "".equals(library.getCategory()) || !Constants.LIBRARY_CATEGORIES.contains(library.getCategory())) .forEach(library -> library.setCategory("Uncategorized")); index = newIndex; } catch (JsonParseException | JsonMappingException e) { System.err.println(format(tr( "Error parsing libraries index: {0}\nTry to open the Library Manager to update the libraries index."), e.getMessage())); } catch (Exception e) { System.err.println(format(tr("Error reading libraries index: {0}"), e.getMessage())); } finally { IOUtils.closeQuietly(indexIn); } }
From source file:cc.arduino.contributions.packages.ContributionsIndexer.java
private ContributionsIndex parseIndex(File indexFile) throws IOException { InputStream inputStream = null; try {// w w w. j av a2 s .co m inputStream = new FileInputStream(indexFile); ObjectMapper mapper = new ObjectMapper(); mapper.registerModule(new MrBeanModule()); mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true); mapper.configure(DeserializationFeature.EAGER_DESERIALIZER_FETCH, true); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); return mapper.readValue(inputStream, ContributionsIndex.class); } finally { IOUtils.closeQuietly(inputStream); } }