writeArray method

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

Implementation

String writeArray(VlJson v, int depth, bool pretty) {
  int total = v.arr.length;
  if ( total == 0 ) {
    return "[]";
  }
  String out = "[";
  int k = 0;
  while (k < total) {
    if ( k > 0 ) {
      out = out + ",";
    }
    if ( pretty ) {
      out = (out + String.fromCharCode(10)) + this.indent((depth + 1));
    }
    VlJson item = v.arr[k];
    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;
}