public static List<Metadata> fromJson(Reader reader) throws IOException {
        List<Metadata> ms = null;
        if (reader == null) {
            return ms;
        }
        ms = new ArrayList<>();
        try (JsonParser jParser = new JsonFactory()
                .setStreamReadConstraints(StreamReadConstraints
                        .builder()
                        .maxStringLength(TikaConfig.getMaxJsonStringFieldLength())
                        .build())
                .createParser(CloseShieldReader.wrap(reader))) {

            JsonToken token = jParser.nextToken();
            if (token != JsonToken.START_ARRAY) {
                throw new IOException("metadata list must start with an array, but I see: " + token.name());
            }
            token = jParser.nextToken();
            while (token != JsonToken.END_ARRAY) {
                Metadata m = JsonMetadata.readMetadataObject(jParser);
                ms.add(m);
                token = jParser.nextToken();
            }

        }
        if (ms == null) {
            return null;
        }
        //if the last object is the main document,
        //as happens with the streaming serializer,
        //flip it to be the first element.
        if (ms.size() > 1) {
            Metadata last = ms.get(ms.size() - 1);
            String embResourcePath = last.get(TikaCoreProperties.EMBEDDED_RESOURCE_PATH);
            if (embResourcePath == null && ms
                    .get(0)
                    .get(TikaCoreProperties.EMBEDDED_RESOURCE_PATH) != null) {
                ms.add(0, ms.remove(ms.size() - 1));
            }
        }
        return ms;
    }
@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);
    }