public static dynamic Parse(string jsonString) { try { var result = JsonToDynamic.ToDynamic(JsonConvert.DeserializeObject <JContainer>(jsonString)); return(result); } catch { try { var jarray = JsonConvert.DeserializeObject <JArray>(jsonString); return(JsonToDynamic.ToArray(jarray)); } catch { bool valueAsBool = false; int valueAsInt = 0; double valueAsDouble = 0; DateTime valueAsDateTime = DateTime.MinValue; if (bool.TryParse(jsonString, out valueAsBool)) { return(valueAsBool); } if (int.TryParse(jsonString, out valueAsInt)) { return(valueAsInt); } if (double.TryParse(jsonString, out valueAsDouble)) { return(valueAsDouble); } if (DateTime.TryParse(jsonString, out valueAsDateTime)) { return(valueAsDateTime); } return(jsonString); } } }
public static object JsonToGemini(this Stream s) { return(JsonToDynamic.Parse(new StreamReader(s.FromBeginning()).ReadToEnd())); }