net.krotscheck.dfr.json.JSONDataDecoder Maven / Gradle / Ivy
The newest version!
/*
* Copyright (c) 2014 Michael Krotscheck
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.krotscheck.dfr.json;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import net.krotscheck.dfr.text.AbstractTextDecoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.Reader;
import java.util.Iterator;
import java.util.Map;
/**
* This data decoder will read in a Json encoded file and generate objects for
* every row found. Note that no significant error checking is performed here,
* the file is assumed to be an array of un-nested objects.
*
* @author Michael Krotscheck
*/
public final class JSONDataDecoder extends AbstractTextDecoder {
/**
* Logger instance.
*/
private static Logger logger =
LoggerFactory.getLogger(JSONDataDecoder.class);
/**
* Create the iterator for the JSON file.
*
* @return An iterator.
*/
@Override
protected Iterator
© 2015 - 2025 Weber Informatics LLC | Privacy Policy