Example #1
0
        /// <summary>
        /// 对象转换 JSON 字符串(单线程模式)
        /// </summary>
        /// <typeparam name="valueType">目标数据类型</typeparam>
        /// <param name="value">数据对象</param>
        /// <param name="config">配置参数</param>
        /// <returns>JSON 字符串</returns>
        public static string SerializeThread <valueType>(ref valueType value, SerializeConfig config = null)
        {
            Serializer jsonSerializer = ThreadStatic.Get().Serializer;

            try
            {
                return(jsonSerializer.serializeThread <valueType>(ref value, config));
            }
            finally { jsonSerializer.freeThread(); }
        }
Example #2
0
        /// <summary>
        /// 对象转换 JSON 字符串(单线程模式)
        /// </summary>
        /// <typeparam name="valueType">目标数据类型</typeparam>
        /// <param name="value">数据对象</param>
        /// <param name="config">配置参数</param>
        /// <returns>JSON 字符串</returns>
        public static SerializeResult SerializeThread <valueType>(valueType value, SerializeConfig config = null)
        {
            Serializer jsonSerializer = ThreadStatic.Get().Serializer;

            try
            {
                string json = jsonSerializer.serializeThread <valueType>(ref value, config);
                return(new SerializeResult {
                    Json = json, Warning = jsonSerializer.Warning
                });
            }
            finally { jsonSerializer.freeThread(); }
        }