SimpleJSON.JSONNode.Escape C# (CSharp) Method

Escape() static private method

static private Escape ( string aText ) : string
aText string
return string
		internal static string Escape(string aText)
		{
			string result = "";
			foreach (char c in aText)
			{
				switch (c)
				{
					case '\\':
						result += "\\\\";
						break;
					case '\"':
						result += "\\\"";
						break;
					case '\n':
						result += "\\n";
						break;
					case '\r':
						result += "\\r";
						break;
					case '\t':
						result += "\\t";
						break;
					case '\b':
						result += "\\b";
						break;
					case '\f':
						result += "\\f";
						break;
					default:
						result += c;
						break;
				}
			}
			return result;
		}

Usage Example

        public override string ToString(string aPrefix)
        {
            string text = "{ ";

            using (Dictionary <string, JSONNode> .Enumerator enumerator = this.m_Dict.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    KeyValuePair <string, JSONNode> current = enumerator.get_Current();
                    if (text.get_Length() > 3)
                    {
                        text += ", ";
                    }
                    text = text + "\n" + aPrefix + "   ";
                    string text2 = text;
                    text = string.Concat(new string[]
                    {
                        text2,
                        "\"",
                        JSONNode.Escape(current.get_Key()),
                        "\" : ",
                        current.get_Value().ToString(aPrefix + "   ")
                    });
                }
            }
            text = text + "\n" + aPrefix + "}";
            return(text);
        }
All Usage Examples Of SimpleJSON.JSONNode::Escape