All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.simple4j.wsclient.parser.impl.JSONParser Maven / Gradle / Ivy

package org.simple4j.wsclient.parser.impl;

import java.io.IOException;
import java.util.Map;

import org.simple4j.wsclient.exception.SystemException;
import org.simple4j.wsclient.parser.IParser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * This implementation parses JSON string to Java Collections object tree.
 * 
 * @author jsrinivas108
 */
public class JSONParser implements IParser
{

	private static Logger logger = LoggerFactory.getLogger(JSONParser.class);

	public Map parseData(String arg)
	{
		ObjectMapper jsonMapper = new ObjectMapper();
		try
		{
			return jsonMapper.readValue(arg, Map.class);
		} catch (IOException e)
		{
			logger.error("Error while parsing JSON : >{}<", arg);
			throw new SystemException("JSON_PARSE_FAILED", e);
		}
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy