Java Json Parse json2Obj(String json, Class clazz)

Here you can find the source of json2Obj(String json, Class clazz)

Description

json Obj

License

Apache License

Declaration

public static <T> T json2Obj(String json, Class<T> clazz) 

Method Source Code


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

import java.text.SimpleDateFormat;

import com.fasterxml.jackson.databind.ObjectMapper;

public class Main {

    public static <T> T json2Obj(String json, Class<T> clazz) {
        ObjectMapper objectMapper = new ObjectMapper();
        try {//from   www. j  av  a  2 s  .com
            objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
            return objectMapper.readValue(json, clazz);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}

Related

  1. getMapFromGson(String json)
  2. jsonString(String s)
  3. parse(JSONObject jsonobj)
  4. parse(String json, Class tClass)
  5. parseDateFromJsonArray(final JsonArray array)