/// <summary> /// 입력한 이름에 해당하는 하위 JValue를 가져옵니다. /// </summary> /// <param name="key">이름</param> /// <returns>입력한 이름에 존재하는 JValue 값.</returns> /// <example> /// <code> /// var x = JValue.Parse("{hello:{world:10}}"); /// Trace.Assert(x["hello"]["world"] == 10); /// </code> /// </example> public JValue Get(string key) { if (Type == TypeCode.Object) { int end = startIndex + length - 1; int kStart = SkipWhitespaces(startIndex + 1); while (kStart < end) { int kEnd = SkipString(kStart); int vStart = SkipWhitespaces(kEnd + 1); int vEnd = SkipValue(vStart); kStart++; // remove quotes kEnd--; // remove quotes if (key.Length == kEnd - kStart && JValueExtension.Equals(key, 0, source, kStart, key.Length)) { return(new JValue(source, vStart, vEnd - vStart)); } kStart = SkipWhitespaces(vEnd + 1); } } return(JValue.Null); }
private long AsLongActually(long defaultValue = 0) { if (IsInteger()) { return(JValueExtension.Parse(source, startIndex, length, defaultValue)); } else { return((long)JValueExtension.Parse(source, startIndex, length, (double)defaultValue)); } }
private int AsIntActually(int defaultValue = 0) { if (IsInteger()) { return(JValueExtension.Parse(source, startIndex, length, defaultValue)); } else { return((int)JValueExtension.Parse(source, startIndex, length, (double)defaultValue)); } }
public double AsDouble(double defaultValue = 0.0) { switch (Type) { case TypeCode.Boolean: return(AsBooleanActually() ? 1 : 0); case TypeCode.Number: return(AsDoubleActually(defaultValue)); case TypeCode.String: return(JValueExtension.Parse(source, startIndex + 1, length - 2, defaultValue)); default: return(defaultValue); } }
private double AsDoubleActually(double defaultValue = 0.0) { return(JValueExtension.Parse(source, startIndex, length, defaultValue)); }
private float AsFloatActually(float defaultValue = 0.0f) { return(JValueExtension.Parse(source, startIndex, length, defaultValue)); }