Firstborn/Library/PackageCache/com.unity.ads@3.7.5/Runtime/Monetization/JavaMapUtilities.cs

26 lines
757 B
C#
Raw Normal View History

2023-03-28 13:24:16 -04:00
using System.Collections.Generic;
namespace UnityEngine.Monetization
{
internal class JavaMapUtilities
{
public static IDictionary<string, object> GetDictionaryForJavaMap(AndroidJavaObject javaMap)
{
if (javaMap == null)
{
return new Dictionary<string, object>();
}
var jsonJavaObject = new AndroidJavaObject("org.json.JSONObject", javaMap);
var json = jsonJavaObject.Call<string>("toString");
var jsonObject = MiniJSON.Json.Deserialize(json);
if (jsonObject is IDictionary<string, object> objects)
{
return objects;
}
return new Dictionary<string, object>();
}
}
}