예제 #1
0
        private static object CallReduce(ReduceDelegate reduce, IList <object> keys, IList <object> vals)
        {
            if (reduce == null)
            {
                return(null);
            }

#if PARSED_KEYS
            var lazyKeys = keys;
#else
            var lazyKeys = new LazyJsonArray(keys);
#endif

            var lazyValues = new LazyJsonArray(vals);
            try {
                var result = reduce(lazyKeys, lazyValues, false);
                if (result != null)
                {
                    return(result);
                }
            } catch (Exception e) {
                Log.To.Query.W(Tag, "Exception in reduce block, returning null", e);
            }

            return(null);
        }
        private static object CallReduce(ReduceDelegate reduce, List <object> keysToReduce, List <object> valuesToReduce)
        {
            if (reduce == null)
            {
                return(null);
            }

            var lazyKeys = new LazyJsonArray(keysToReduce);
            var lazyVals = new LazyJsonArray(valuesToReduce);

            try {
                object result = reduce(lazyKeys, lazyVals, false);
                if (result != null)
                {
                    return(result);
                }
            } catch (Exception e) {
                Log.E(TAG, "Exception in reduce block", e);
            }

            return(null);
        }
        private static object CallReduce(ReduceDelegate reduce, List <object> keysToReduce, List <object> valuesToReduce)
        {
            if (reduce == null)
            {
                return(null);
            }

            var lazyKeys = new LazyJsonArray(keysToReduce);
            var lazyVals = new LazyJsonArray(valuesToReduce);

            try {
                object result = reduce(lazyKeys, lazyVals, false);
                if (result != null)
                {
                    return(result);
                }
            } catch (Exception e) {
                Log.To.Query.E(Tag, String.Format("Failed to reduce query (keys={0} vals={1}), returning null...",
                                                  new SecureLogJsonString(keysToReduce, LogMessageSensitivity.PotentiallyInsecure),
                                                  new SecureLogJsonString(valuesToReduce, LogMessageSensitivity.PotentiallyInsecure)), e);
            }

            return(null);
        }
예제 #4
0
 //Return a JSON object from the json data
 //If the Json starts with  '{' or a '[' then no parsing takes place and the
 //data is wrapped in a LazyJsonObject or a LazyJsonArray which will delay parsing until
 //values are requested
 public virtual object JsonObject()
 {
     if (json == null)
     {
         return null;
     }
     if (cached == null)
     {
         object tmp = null;
         if (json[0] == '{')
         {
             tmp = new LazyJsonObject<string, object>(json);
         }
         else
         {
             if (json[0] == '[')
             {
                 tmp = new LazyJsonArray<object>(json);
             }
             else
             {
                 try
                 {
                     tmp = Manager.GetObjectMapper().ReadValue<object>(json);
                 }
                 catch (Exception e)
                 {
                     //cached will remain null
                     Log.W(Database.Tag, "Exception parsing json", e);
                 }
             }
         }
         cached = tmp;
     }
     return cached;
 }