Ejemplo n.º 1
0
		//@predefined converter
		public static string fromListOfObject(object value, bool useSingleQuote)
		{
			if (value == null)
			{
				return JsonBuilder.NullStr;
			}
			if (value.GetType() == typeof(List<object>))
			{
				var elems = value as List<object>;
				var jb = new JsonBuilder(useSingleQuote);
				jb.startArray();
				foreach (object elem in elems)
				{
					jb.addValue(elem);
				}
				jb.endArray();
				return jb.toJSON();
			}
			return JsonBuilder.NullStr;
		}
Ejemplo n.º 2
0
		//@predefined converter
		public static string fromAnyArray(object value, bool useSingleQuote)
		{
			if (value == null)
			{
				return JsonBuilder.NullStr;
			}
			if ((value.GetType()).IsArray)
			{
				var elems = value as Array;
				var jb = new JsonBuilder(useSingleQuote);
				jb.startArray();
				foreach (object elem in elems)
				{
					jb.addValue(elem);
				}
				jb.endArray();
				return jb.toJSON();
			}
			return JsonBuilder.NullStr;
		}
Ejemplo n.º 3
0
 //@predefined converter
 public static string fromAnyArray(object value, bool useSingleQuote)
 {
     if (value == null)
     {
         return(JsonBuilder.NullStr);
     }
     if ((value.GetType()).IsArray)
     {
         var elems = value as Array;
         var jb    = new JsonBuilder(useSingleQuote);
         jb.startArray();
         foreach (object elem in elems)
         {
             jb.addValue(elem);
         }
         jb.endArray();
         return(jb.toJSON());
     }
     return(JsonBuilder.NullStr);
 }
Ejemplo n.º 4
0
 //@predefined converter
 public static string fromListOfObject(object value, bool useSingleQuote)
 {
     if (value == null)
     {
         return(JsonBuilder.NullStr);
     }
     if (value.GetType() == typeof(List <object>))
     {
         var elems = value as List <object>;
         var jb    = new JsonBuilder(useSingleQuote);
         jb.startArray();
         foreach (object elem in elems)
         {
             jb.addValue(elem);
         }
         jb.endArray();
         return(jb.toJSON());
     }
     return(JsonBuilder.NullStr);
 }
Ejemplo n.º 5
0
		//@predefined converter
		public static string fromHashtable(object value, bool useSingleQuote)
		{
			if (value == null)
			{
				return JsonBuilder.NullStr;
			}
			//
			if (value.GetType() == typeof(Hashtable))
			{
				var elems = value as Hashtable;
				var jb = new JsonBuilder(useSingleQuote);
				jb.startObject();
				foreach (object key in elems.Keys)
				{
					jb.add(key.ToString(), elems[key]);
				}
				jb.endObject();
				return jb.toJSON();
			}
			return JsonBuilder.NullStr;
		}
Ejemplo n.º 6
0
 //@predefined converter
 public static string fromDictionaryOfObject(object value, bool useSingleQuote)
 {
     if (value == null)
     {
         return(JsonBuilder.NullStr);
     }
     //
     if (value.GetType() == typeof(Dictionary <string, object>))
     {
         var elems = value as Dictionary <string, object>;
         var jb    = new JsonBuilder(useSingleQuote);
         jb.startObject();
         foreach (string key in elems.Keys)
         {
             jb.add(key, elems[key]);
         }
         jb.endObject();
         return(jb.toJSON());
     }
     return(JsonBuilder.NullStr);
 }
Ejemplo n.º 7
0
 //@predefined converter
 public static string fromHashtable(object value, bool useSingleQuote)
 {
     if (value == null)
     {
         return(JsonBuilder.NullStr);
     }
     //
     if (value.GetType() == typeof(Hashtable))
     {
         var elems = value as Hashtable;
         var jb    = new JsonBuilder(useSingleQuote);
         jb.startObject();
         foreach (object key in elems.Keys)
         {
             jb.add(key.ToString(), elems[key]);
         }
         jb.endObject();
         return(jb.toJSON());
     }
     return(JsonBuilder.NullStr);
 }
Ejemplo n.º 8
0
		public string FieldsToJson()
		{
            if (Fields == null || Fields.Count == 0)
            {
                throw new ArgumentException("fields cant't be null or empty");
            }

			var jsonBuilder = new JsonBuilder();
			jsonBuilder.startObject();
			foreach (var variable in Fields)
			{
				jsonBuilder.add(variable.Key, variable.Value);
			}
			jsonBuilder.endObject();
			return  jsonBuilder.toJSON();
		}
Ejemplo n.º 9
0
		//@predefined converter
		public static string fromDictionaryOfObject(object value, bool useSingleQuote)
		{
			if (value == null)
			{
				return JsonBuilder.NullStr;
			}
			//
			if (value.GetType() == typeof(Dictionary<string, object>))
			{
				var elems = value as Dictionary<string, object>;
				var jb = new JsonBuilder(useSingleQuote);
				jb.startObject();
				foreach (string key in elems.Keys)
				{
					jb.add(key, elems[key]);
				}
				jb.endObject();
				return jb.toJSON();
			}
			return JsonBuilder.NullStr;
		}