Example #1
0
        /// <summary>
        ///     Serialize objects into JSON strings
        /// </summary>
        /// <typeparam name="T">Value type</typeparam>
        /// <param name="value">Value</param>
        /// <param name="option">Serialize option</param>
        /// <returns>JSON strings</returns>
        public static string ToJson <T>(T value, JsonSerializerOption option)
        {
            var handler = new JsonSerializerHandler {
                Option = option
            };

            Serializer.FormattingProvider <T> .Get(value, handler);

            return(handler.ToString());
        }
Example #2
0
        /// <summary>
        ///     Serialize objects into JSON strings
        /// </summary>
        /// <typeparam name="T">Value type</typeparam>
        /// <param name="value">Value</param>
        /// <param name="option">Serialize option</param>
        /// <returns>JSON strings</returns>
        public static string ToJson <T>(T value, JsonSerializerOption option = null)
        {
            var handler = new JsonSerializerHandler(new System.Text.StringBuilder())
            {
                Option = option ?? defaultSerializerOption
            };

            Serializer.FormattingProvider <T> .Get(value, handler);

            return(handler.ToString());
        }