writeObject method

String writeObject(
  1. VlJson v,
  2. int depth,
  3. bool pretty
)

Implementation

String writeObject(VlJson v, int depth, bool pretty) {
  int total = v.keys.length;
  if ( total == 0 ) {
    return "{}";
  }
  String out = "{";
  int k = 0;
  while (k < total) {
    String key = v.keys[k];
    if ( k > 0 ) {
      out = out + ",";
    }
    if ( pretty ) {
      out = (out + String.fromCharCode(10)) + this.indent((depth + 1));
    }
    out = (out + this.quote(key)) + ":";
    if ( pretty ) {
      out = out + " ";
    }
    VlJson item = v._get(key);
    out = out + this.writeValue(item, (depth + 1), pretty);
    k = k + 1;
  }
  if ( pretty ) {
    out = ((out + String.fromCharCode(10)) + this.indent(depth)) + "}";
  } else {
    out = out + "}";
  }
  return out;
}