public JMbr(bool v, string name = null) { this.name = name; type = v ? JType.True : JType.False; refv = null; numv = default; }
public JMbr(JNumber v, string name = null) { this.name = name; type = JType.Number; refv = null; numv = v; }
public JMbr(JArr v, string name = null) { this.name = name; type = JType.Array; refv = v; numv = default; }
public JMbr(string v, string name = null) { this.name = name; type = JType.String; refv = v; numv = default; }
public JMbr(JType jnull, string name = null) { this.name = name; type = jnull; refv = null; numv = default; }
public JMbr(JObj v, string name = null) { this.name = name; type = JType.Object; refv = v; numv = default; }
public void Add(JNumber v) { Add(v.Long); if (v.Pt) { Add('.'); Add(v.fract); } }
public void Put(string name, JNumber v) { Add(' '); Add(name); Add('='); Add('"'); Add(v); Add('"'); }
public void Put(string name, JNumber v) { Part(name); Add(v.bigint); if (v.Pt) { Add('.'); Add(v.fract); } }
public static decimal ParseDecimal(this string str, ref int pos, char sep = '-') { int len = str.Length; if (pos >= len) { return(0); } if (str[pos] == sep) { pos++; // skip sep } JNumber num = new JNumber(str[pos]); int p = pos; for (;;) { if (p >= len - 1) { break; } int b = str[++p]; if (b == '.') { num.Pt = true; } else if (b >= '0' && b <= '9') { num.Add(b); } else { pos = p - 1; return(num); } } pos = p; return(num.Decimal); }
public void Put(string name, JNumber v) { if (counts[level]++ > 0) { Add(','); } if (name != null) { Add('"'); Add(name); Add('"'); Add(':'); } Add(v.bigint); if (v.Pt) { Add('.'); Add(v.fract); } }
public void Add(JNumber elem) { Add(new JMbr(elem)); }
public void Add(string name, JNumber v) { Add <JMbr>(new JMbr(v, name)); }
public void Put(string name, JNumber v) { }