private static string Filter(string a, JSONChildrenType type) { string ret = a; switch (type) { case JSONChildrenType.STRING: ret = ret.Replace("\\", "\\\\"); ret = ret.Replace("\"", "\\\""); ret = ret.Replace("\n", "\\\n"); ret = ret.Replace("\r", " "); ret = ret.Replace("\t", " "); ret = "\"" + ret + "\""; ret = Json.EncodeNonAsciiCharacters(ret); break; case JSONChildrenType.BOOLEAN: if (Convert.ToBoolean(ret) == true) { ret = "true"; } else { ret = "false"; } break; } return(ret); }
public Json this[string index] { get { if (!childrens.ContainsKey(index)) { childrens[index] = new Json(); } childrenType = JSONChildrenType.DICTIONARY; return(childrens[index]); } set { childrens[index] = value; single_value = ""; childrenType = JSONChildrenType.DICTIONARY; } }
public Json(object value) { single_value = value.ToString(); childrenType = JSONChildrenType.STRING; }
public Json(bool value) { single_value = value.ToString(); childrenType = JSONChildrenType.BOOLEAN; }
public Json(int value) { single_value = value.ToString(); childrenType = JSONChildrenType.INT; }
public Json(double value) { single_value = value.ToString(); childrenType = JSONChildrenType.DOUBLE; }
public Json(string value) { single_value = value; childrenType = JSONChildrenType.STRING; }
public Json() { childrenType = JSONChildrenType.NULL; }