Exemplo n.º 1
0
Arquivo: Json.cs Projeto: i-e-b/ADSD
        /// <summary> Turn an object into a JSON string </summary>
        public static string Freeze(object obj)
        {
            if (IsAnonymousTypedObject(obj))
            { // If we are passed an anon type, turn off type information -- it will all be junk.
                var jsonParameters = DefaultParameters.Clone();
                jsonParameters.UseExtensions        = false;
                jsonParameters.UsingGlobalTypes     = false;
                jsonParameters.EnableAnonymousTypes = true;

                return(Instance.ToJson(obj, jsonParameters));
            }
            return(Instance.ToJson(obj, DefaultParameters));
        }
Exemplo n.º 2
0
Arquivo: Json.cs Projeto: i-e-b/ADSD
        /// <summary> Write an object to a stream as a JSON string </summary>
        public static void Freeze(object obj, Stream target, Encoding encoding = null)
        {
            if (encoding == null)
            {
                encoding = DefaultStreamEncoding;
            }

            if (IsAnonymousTypedObject(obj))
            { // If we are passed an anon type, turn off type information -- it will all be junk.
                var jsonParameters = DefaultParameters.Clone();
                jsonParameters.UseExtensions        = false;
                jsonParameters.UsingGlobalTypes     = false;
                jsonParameters.EnableAnonymousTypes = true;

                Instance.ToJsonStream(obj, target, jsonParameters, encoding);
            }
            Instance.ToJsonStream(obj, target, DefaultParameters, encoding);
        }