public bool ContainsValue(JsonNode value) { return(m_dictionary.ContainsValue(value)); }
public void Add(string key, JsonNode value) { m_dictionary.Add(key, value); }
public JsonNode GetValue(string key, JsonNode defaultValue = default(JsonNode)) { JsonNode value; return(m_dictionary.TryGetValue(key, out value) ? value : defaultValue); }
private static JsonNode ParseJsonPart(string jsonPart) { JsonNode jsonPartValue = null; if (jsonPart.Length == 0) { return(jsonPartValue); } switch (jsonPart[0]) { case JsonNode.CHAR_CURLY_OPEN: { JsonObject jsonObject = new JsonObject(); List <string> splittedParts = SplitJsonParts(jsonPart.Substring(1, jsonPart.Length - 2)); string[] keyValueParts = new string[2]; foreach (string keyValuePart in splittedParts) { keyValueParts = SplitKeyValuePart(keyValuePart); if (keyValueParts [0] != null) { jsonObject [JsonNode.UnescapeString(keyValueParts [0])] = ParseJsonPart(keyValueParts [1]); } } jsonPartValue = jsonObject; } break; case JsonNode.CHAR_SQUARED_OPEN: { JsonArray jsonArray = new JsonArray(); List <string> splittedParts = SplitJsonParts(jsonPart.Substring(1, jsonPart.Length - 2)); foreach (string part in splittedParts) { if (part.Length > 0) { jsonArray.Add(ParseJsonPart(part)); } } jsonPartValue = jsonArray; } break; case JsonNode.CHAR_QUOTE: { jsonPartValue = new JsonBasic(JsonNode.UnescapeString(jsonPart.Substring(1, jsonPart.Length - 2))); } break; case JsonNode.CHAR_FALSE_LITERAL: //false { jsonPartValue = new JsonBasic(false); } break; case JsonNode.CHAR_TRUE_LITERAL: //true { jsonPartValue = new JsonBasic(true); } break; case JsonNode.CHAR_NULL_LITERAL: //null { jsonPartValue = null; } break; default: //it must be a number or it will fail { long longValue = 0; if (long.TryParse(jsonPart, NumberStyles.Any, CultureInfo.InvariantCulture, out longValue)) { if (longValue > int.MaxValue || longValue < int.MinValue) { jsonPartValue = new JsonBasic(longValue); } else { jsonPartValue = new JsonBasic((int)longValue); } } else { decimal decimalValue = 0; if (decimal.TryParse(jsonPart, NumberStyles.Any, CultureInfo.InvariantCulture, out decimalValue)) { jsonPartValue = new JsonBasic(decimalValue); } } } break; } return(jsonPartValue); }