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

org.springframework.social.partnercenter.serialization.Json Maven / Gradle / Ivy

Go to download

A provider extension for Spring Social to enable connectivity with Microsoft and an API binding for Microsoft's Partner Center API.

There is a newer version: 10.11.0
Show newest version
package org.springframework.social.partnercenter.serialization;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;

public class Json {
	private static ObjectMapper objectMapper;

	static {
		objectMapper = new ObjectMapper();
	}

	public static  T fromJson(String jsonString, Class targetClass){
		try {
			ObjectReader reader = objectMapper.reader(targetClass);
			return reader.readValue(jsonString);

		} catch (IOException e) {
			throw new JsonSerializationException(e);
		}
	}

	public static  String toJson(T objectToSerialize){
		try {

			return objectMapper.writer().writeValueAsString(objectToSerialize);
		} catch (JsonProcessingException e) {
			throw new JsonSerializationException(e);
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy