JsonUtils

package com.platform.usercenter.utils;

import com.google.gson.Gson;
import com.platform.usercenter.tools.Preconditions;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 

Title: JsonUtils

*

Description: JsonUtils

*

Copyright (c) 2019 www.oppo.com Inc. All rights reserved.

*

Company: OPPO

* * @author Wangmingming * @version 1.0 */ public class JsonUtils { public static String toJson(Object obj) { if (obj == null) { return ""; } return new Gson().toJson(Preconditions.checkNotNull(obj)); } public static String arrayToString(List list) { Gson g = new Gson(); return g.toJson(list); } public static List stringToArray(String s, Class clazz) { T[] arr = new Gson().fromJson(s, clazz);

你可能感兴趣的:(泛型)