<commit_before>package br.com.dbsoft.json;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.type.TypeFactory;

import br.com.dbsoft.error.DBSIOException;
import br.com.dbsoft.util.DBSObject;

public class DBSJson {

//	private static Logger wLogger = Logger.getLogger(DBSJSON.class);

	/**
	 * Retorna String JSon a partir de objeto informado
	 * @param pObject
	 * @return
	 * @throws JsonProcessingException 
	 * @throws DBSIOException
	 */
	public static <T> String toJson(T pObject){
		if (DBSObject.isNull(pObject)) {return null;}
		ObjectMapper xJSON = pvCreateJson();
		xJSON.setPropertyNamingStrategy(null);
		try {
			return xJSON.writeValueAsString(pObject);
		} catch (JsonProcessingException e) {
			e.printStackTrace();
		}
		return "";
	}
	
	/**
	 * Retorna classe do tipo informado a partir de String JSon  
	 * @param pObject
	 * @param pClass
	 * @return
	 * @throws DBSIOException
	 */
	public static <T> T fromJson(Object pObject, Class<T> pClass){<commit_msg>Em caso de parametro nulo, retorna uma string vazia;<commit_after>package br.com.dbsoft.json;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.type.TypeFactory;

import br.com.dbsoft.error.DBSIOException;
import br.com.dbsoft.util.DBSObject;

public class DBSJson {

//	private static Logger wLogger = Logger.getLogger(DBSJSON.class);

	/**
	 * Retorna String JSon a partir de objeto informado
	 * @param pObject
	 * @return
	 * @throws JsonProcessingException 
	 * @throws DBSIOException
	 */
	public static <T> String toJson(T pObject){
		if (DBSObject.isNull(pObject)) {return "";}
		ObjectMapper xJSON = pvCreateJson();
		xJSON.setPropertyNamingStrategy(null);
		try {
			return xJSON.writeValueAsString(pObject);
		} catch (JsonProcessingException e) {
			e.printStackTrace();
		}
		return "";
	}
	
	/**
	 * Retorna classe do tipo informado a partir de String JSon  
	 * @param pObject
	 * @param pClass
	 * @return
	 * @throws DBSIOException
	 */
	public static <T> T fromJson(Object pObject, Class<T> pClass){
{'fraction_non_alphanumeric': 0.10710128055878929, 'fraction_numerical': 0.0, 'mean_word_length': 4.616557734204793, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4144106', 'n_tokens_mistral': 895, 'n_tokens_neox': 788, 'n_words': 190}