Java Json to Object jsonToList(String json, Class parametrized, Class... parameterClasses)

Here you can find the source of jsonToList(String json, Class parametrized, Class... parameterClasses)

Description

json To List

License

Apache License

Declaration

public static <T> T jsonToList(String json, Class<?> parametrized, Class<?>... parameterClasses) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.TypeFactory;

public class Main {
    private static final ObjectMapper MAPPER = new ObjectMapper();

    public static <T> T jsonToList(String json, Class<?> parametrized, Class<?>... parameterClasses) {
        try {//from w  ww. j  a v  a2 s  .co m
            TypeFactory typeFactory = MAPPER.getTypeFactory();

            return MAPPER.readValue(json, typeFactory.constructParametricType(parametrized, parameterClasses));
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }
}

Related

  1. json2map(String jsonStr)
  2. json2pojo(String jsonStr, Class clazz)
  3. jsonBigDecimal(JsonValue value)
  4. jsonStringToList(String jsonArrStr, Class clazz)
  5. jsonToBeanDateSerializer(String jsonStr, Class cl, final String pattern)
  6. jsonToList(String jsonStr, TypeReference valueTypeRef)
  7. jsonToMap(String src)
  8. jsonToObj(String json, Class clazz)
  9. jsonToObj(String json, Class valueType)