Beispiel #1
0
        /// <summary>
        /// Serializes a dictionary to a JSON string
        /// </summary>
        /// <typeparam name="K">The type of the dictionary's keys</typeparam>
        /// <typeparam name="V">The type of the dictionary's values</typeparam>
        /// <param name="dict">The dictionary which should be serialized</param>
        /// <param name="prettyPrint">If true, the JSON string will be formatted to be better human-readable</param>
        /// <returns>Returns the serialized JSON string</returns>
        public static string ToJson <K, V>(Dictionary <K, V> dict, bool prettyPrint = false)
        {
            JsonDictionary <K, V> serialized = JsonDictionary <K, V> .FromDictionary(dict);

            return(JsonUtility.ToJson(serialized, prettyPrint));
        }