Rhino.NativeJSON.Jo C# (CSharp) Method

Jo() private static method

private static Jo ( Scriptable value, NativeJSON state ) : string
value Scriptable
state NativeJSON
return string
		private static string Jo(Scriptable value, NativeJSON.StringifyState state)
		{
			if (state.stack.Search(value) != -1)
			{
				throw ScriptRuntime.TypeError0("msg.cyclic.value");
			}
			state.stack.Push(value);
			string stepback = state.indent;
			state.indent = state.indent + state.gap;
			object[] k = null;
			if (state.propertyList != null)
			{
				k = Sharpen.Collections.ToArray(state.propertyList);
			}
			else
			{
				k = value.GetIds();
			}
			IList<object> partial = new List<object>();
			foreach (object p in k)
			{
				object strP = Str(p, value, state);
				if (strP != Undefined.instance)
				{
					string member = Quote(p.ToString()) + ":";
					if (state.gap.Length > 0)
					{
						member = member + " ";
					}
					member = member + strP;
					partial.Add(member);
				}
			}
			string finalValue;
			if (partial.IsEmpty())
			{
				finalValue = "{}";
			}
			else
			{
				if (state.gap.Length == 0)
				{
					finalValue = '{' + Join(partial, ",") + '}';
				}
				else
				{
					string separator = ",\n" + state.indent;
					string properties = Join(partial, separator);
					finalValue = "{\n" + state.indent + properties + '\n' + stepback + '}';
				}
			}
			state.stack.Pop();
			state.indent = stepback;
			return finalValue;
		}