using System;
using System.Collections;
using System.Collections.Generic;
using LitJson;
#if !COMBAT_SERVER
using UnityEngine;

#else
using System.Text.Json;
#endif

public class JsonManager
{
    public static T FromJson<T>(string json)
    {
        return JsonMapper.ToObject<T>(json);
#if !COMBAT_SERVER
        return JsonUtility.FromJson<T>(json);
#else
       return JsonSerializer.Deserialize<T>(json);
#endif
    }

    public static object FromJson(string json, Type type)
    {
        return JsonMapper.ToObject(json,type);
#if !COMBAT_SERVER
        return JsonUtility.FromJson(json, type);
#else
       JsonSerializerOptions jo = new JsonSerializerOptions();
       // jo.IgnoreNullValues = true;
          return JsonSerializer.Deserialize(json,type,jo);
#endif
    }

    public static string ToJson(object obj)
    {
        return JsonMapper.ToJson(obj);
#if !COMBAT_SERVER
        return JsonUtility.ToJson(obj);
#else
       return JsonSerializer.Serialize(obj);
#endif
    }
}