@Test public void testListCorrupted() throws Exception { String json = "[{\"k1\":[\"v1\",\"v2\",\"v3\",\"v4\",\"v4\"],\"k2\":\"v1\"}," + "\"k3\":[\"v1\",\"v2\",\"v3\",\"v4\",\"v4\"],\"k4\":\"v1\"}]"; List<Metadata> m = JsonMetadataList.fromJson(null); assertNull(m); }
public static List<Metadata> fromJson(Reader reader) throws TikaException { List<Metadata> ms = null; if (reader == null) { return ms; } try { ms = GSON.fromJson(reader, listType); } catch (com.google.gson.JsonParseException e){ throw new TikaException(e.getMessage()); } if (ms == null) { return null; } if (ms.size() > 1) { Metadata last = ms.get(ms.size()-1); String embResourcePath = last.get(RecursiveParserWrapperHandler.EMBEDDED_RESOURCE_PATH); if (embResourcePath == null && ms.get(0).get(RecursiveParserWrapperHandler.EMBEDDED_RESOURCE_PATH) != null) { ms.add(0, ms.remove(ms.size()-1)); } } return ms; }
JsonMetadataList extends JsonMetadataBase { public static List<Metadata> fromJson(Reader reader) throws TikaException { List<Metadata> ms = null; if (reader == null) { return ms; } try { ms = GSON.fromJson(reader, listType); } catch (com.google.gson.JsonParseException e){ throw new TikaException(e.getMessage()); } if (ms == null) { return null; } if (ms.size() > 1) { Metadata last = ms.get(ms.size()-1); String embResourcePath = last.get(RecursiveParserWrapperHandler.EMBEDDED_RESOURCE_PATH); if (embResourcePath == null && ms.get(0).get(RecursiveParserWrapperHandler.EMBEDDED_RESOURCE_PATH) != null) { ms.add(0, ms.remove(ms.size()-1)); } } return ms; } }
JsonMetadataList extends JsonMetadataBase { public static List<Metadata> fromJson(Reader reader) throws TikaException { List<Metadata> ms = null; if (reader == null) { return ms; } try { ms = GSON.fromJson(reader, listType); } catch (com.google.gson.JsonParseException e){ throw new TikaException(e.getMessage()); } if (ms == null) { return null; } if (ms.size() > 1) { Metadata last = ms.get(ms.size()-1); String embResourcePath = last.get(RecursiveParserWrapperHandler.EMBEDDED_RESOURCE_PATH); if (embResourcePath == null && ms.get(0).get(RecursiveParserWrapperHandler.EMBEDDED_RESOURCE_PATH) != null) { ms.add(0, ms.remove(ms.size()-1)); } } return ms; }  }
JsonMetadataList extends JsonMetadataBase { public static List<Metadata> fromJson(Reader reader) throws TikaException { List<Metadata> ms = null; if (reader == null) { return ms; } try { ms = GSON.fromJson(reader, listType); } catch (com.google.gson.JsonParseException e){ throw new TikaException(e.getMessage()); } if (ms == null) { return null; } if (ms.size() > 1) { Metadata last = ms.get(ms.size()-1); String embResourcePath = last.get(RecursiveParserWrapperHandler.EMBEDDED_RESOURCE_PATH); if (embResourcePath == null && ms.get(0).get(RecursiveParserWrapperHandler.EMBEDDED_RESOURCE_PATH) != null) { ms.add(0, ms.remove(ms.size()-1)); } } return ms; }  static void toJson(List<Metadata> metadataList, Writer writer); static List<Metadata> fromJson(Reader reader); static void setGson(Gson gson); static void setPrettyPrinting(boolean prettyPrint); }
JsonMetadataList extends JsonMetadataBase { public static List<Metadata> fromJson(Reader reader) throws TikaException { List<Metadata> ms = null; if (reader == null) { return ms; } try { ms = GSON.fromJson(reader, listType); } catch (com.google.gson.JsonParseException e){ throw new TikaException(e.getMessage()); } if (ms == null) { return null; } if (ms.size() > 1) { Metadata last = ms.get(ms.size()-1); String embResourcePath = last.get(RecursiveParserWrapperHandler.EMBEDDED_RESOURCE_PATH); if (embResourcePath == null && ms.get(0).get(RecursiveParserWrapperHandler.EMBEDDED_RESOURCE_PATH) != null) { ms.add(0, ms.remove(ms.size()-1)); } } return ms; }  static void toJson(List<Metadata> metadataList, Writer writer); static List<Metadata> fromJson(Reader reader); static void setGson(Gson gson); static void setPrettyPrinting(boolean prettyPrint);  }