[git practical] git commit-aDEND revoke, Cherry-Pick operation I

2023-01-21   ES  

JsonUtils

Integrate some operations to JSON:
package com.evan.common.utils; 

 Import java.util.list; 

 Import com.fasterxml.jackson.core.jsonProcessingException; 
 Import com.fasterxml.jackson.databind.javatype; 
 Import com.fasterxml.jackson.dataBind.objectMapper; 

 /** 
  * Taotao Mall customized response structure 
  */ 
 public class jsonutill { 

     // Define the Jackson object 
     Private Static Final ObjectMapper Mapper = New ObjectMapper (); 

     /** 
      * Convert the object to the JSON string. 
      * <p> Title: Pojotojson </p> 
      * <p> description: </p> 
      * @param Data 
      * @Return 
      */ 
     Public Static String Objecttojson (Object Data) {{ 
     try { 
 String string = Mapper.writevalaSstring (data); 
 Return string; 
 } Catch (jsonprocessingException E) {{ 
 e.printstacktrace (); 
 } 
     Return null; 
     } 
    
     /** 
      * Translate the JSON results set into objects 
      * 
      * @param jsondata json data 
      * @param Clazz Object type 
      * @Return 
      */ 
     Public Static <t> T JSONTOPOJO (String JSONDATA, Class <T> Beatype) { 
         try { 
             T = Mapper.readvalue (jsondata, BeAntype); 
             Return T; 
         } Catch (Exception E) { 
         e.printstacktrace (); 
         } 
         Return null; 
     } 
    
     /** 
      * Convert json data to POJO object list 
      * <p> Title: JSONTOLIST </p> 
      * <p> description: </p> 
      * @param jsondata 
      * @param Beatype 
      * @Return 
      */ 
     Public Static <t> List <t> JSONTOLIS 
     Javatype javatype = Mapper.gettypefactory (). Constructor 
     try { 
     List <t> list = mapper.readvalue (jsondata, javatype); 
     Return list; 
 } Catch (Exception E) { 
 e.printstacktrace (); 
 } 
     
     Return null; 
     } 
    
 }

source

Related Posts

VS2015 GDAL (C ++ version) configuration

bzoj1677: [USACO2005 JAN] SumSets

Made in Mario, Ready ~~ GO! “GitHub Hot Speed V.22.16”

Pseudo -static rules of common php source codes (Nginx/Apache)

[git practical] git commit-aDEND revoke, Cherry-Pick operation I

Random Posts

About Navicat Premium error: ORA-12541: TNS: No Listener solution

Intent to pass data PARCLABLE, Serializable, Bundle detailed usage

1 1 1 1 1 1 1 1 1 1 overall review

Raspberry Pi docker run mysql

[javascript] 2. JS compatibility writing of IE/FF