Exemplo n.º 1
0
        /// <summary>
        /// Create a binary json representation for an object with parameter override on this call
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        public static byte[] ToBJSON(object obj, BJSONParameters param)
        {
            param.FixValues();
            param = param.MakeCopy();
            Type t = null;

            if (obj == null)
            {
                return new byte[] { TOKENS.NULL }
            }
            ;
            if (obj.GetType().IsGenericType)
            {
                t = Reflection.Instance.GetGenericTypeDefinition(obj.GetType());// obj.GetType().GetGenericTypeDefinition();
            }
            if (t == typeof(Dictionary <,>) || t == typeof(List <>))
            {
                param.UsingGlobalTypes = false;
            }
            // FEATURE : enable extensions when you can deserialize anon types
            if (param.EnableAnonymousTypes)
            {
                param.UseExtensions = false; param.UsingGlobalTypes = false;
            }

            return(new BJSONSerializer(param).ConvertToBJSON(obj));
        }
Exemplo n.º 2
0
 public deserializer(BJSONParameters param)
 {
     _params = param;
     _params = param.MakeCopy();
 }
Exemplo n.º 3
0
 /// <summary>
 /// Create an object from the json with parameter override on this call
 /// </summary>
 /// <param name="json"></param>
 /// <param name="param"></param>
 /// <returns></returns>
 public static object ToObject(byte[] json, BJSONParameters param)
 {
     param.FixValues();
     param = param.MakeCopy();
     return(new deserializer(param).ToObject(json, null));
 }