Java Json to Object readValue(String jsonStr, Class valueType)

Here you can find the source of readValue(String jsonStr, Class valueType)

Description

read Value

License

Open Source License

Declaration

public static <T> T readValue(String jsonStr, Class<T> valueType) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.SimpleDateFormat;

import com.fasterxml.jackson.databind.ObjectMapper;

public class Main {
    public static <T> T readValue(String jsonStr, Class<T> valueType) {
        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
        try {/*from   ww  w .ja v  a  2  s. c o  m*/
            return objectMapper.readValue(jsonStr, valueType);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return null;
    }
}

Related

  1. jsonToObj(String json, Class valueType)
  2. jsonToObject(String json, Class toValueType)
  3. jsonToObject(String jsonString, Class classOfT)
  4. jsonToPojo(String jsonData, Class beanType)
  5. parse(String jsonLine)
  6. stringForJSON(String input)