OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 142 | Rev 180 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 142 Rev 144
Line 21... Line 21...
21
import java.math.BigInteger;
21
import java.math.BigInteger;
22
import java.text.Format;
22
import java.text.Format;
23
import java.util.Calendar;
23
import java.util.Calendar;
24
import java.util.Date;
24
import java.util.Date;
25
 
25
 
-
 
26
import com.google.gson.Gson;
-
 
27
import com.google.gson.JsonElement;
-
 
28
import com.google.gson.reflect.TypeToken;
-
 
29
 
26
import net.minidev.json.JSONArray;
30
import net.minidev.json.JSONArray;
27
import net.minidev.json.JSONObject;
31
import net.minidev.json.JSONObject;
28
import net.minidev.json.parser.JSONParser;
32
import net.minidev.json.parser.JSONParser;
29
import net.minidev.json.parser.ParseException;
33
import net.minidev.json.parser.ParseException;
30
 
34
 
31
public class JSONConverter {
35
public class JSONConverter {
32
 
36
 
-
 
37
    // type-safe methods
-
 
38
 
-
 
39
    public static final <T> T fromJson(final Gson gson, String json, TypeToken<T> typeOfT) {
-
 
40
        return gson.fromJson(json, typeOfT.getType());
-
 
41
    }
-
 
42
 
-
 
43
    public static final <T> T fromJson(final Gson gson, JsonElement json, TypeToken<T> typeOfT) {
-
 
44
        return gson.fromJson(json, typeOfT.getType());
-
 
45
    }
-
 
46
 
-
 
47
    // ** net.minidev.json
-
 
48
 
33
    static private final Format DF = new XMLDateFormat();
49
    static private final Format DF = new XMLDateFormat();
34
 
50
 
35
    static synchronized private final String format(final Date d) {
51
    static synchronized private final String format(final Date d) {
36
        return DF.format(d);
52
        return DF.format(d);
37
    }
53
    }