Open a single square bracket.

@return this JsonWriter
@throws IOException if an I/O error has occurred
423105
public JsonWriter openSquareBracket() throws IOException {
        if (!willWriteValue) {
            indent();
        }
        writer.write("[");
        nextLine();
        indentDepth++;
        willWriteValue = false;
        return this;
    }
266391
public JsonWriter value(long value) throws IOException {
        beforeValue(false);
        out.write(Long.toString(value));
        return this;
    }
1200039
public void toJson(Writer writer) throws IOException {
		startHash(writer);

		int size = size();
		Set<String> set = keySet();
		int i = 0;
		for (String key : set) {

			putKey(writer, key);
			JsonUtil.put(writer, get(key));

			if (i + 1 < size) {
				addSeparator(writer);
			}
			i++;
		}

		endHash(writer);
	}
1088967
protected JsonWriter property(String key, Object[] array) throws IOException {
      return property(key, Arrays.asList(array));
   }
975340
public String asHex() throws IOException {
        byte[] bytes = asByteArray();
        char[] hex = new char[bytes.length * 2];
        for ( int j = 0; j < bytes.length; j++ ) {
            int v = bytes[j] & 0xFF;
            hex[j * 2] = HEX_ARRAY[v >>> 4];
            hex[j * 2 + 1] = HEX_ARRAY[v & 0x0F];
        }
        return new String(hex);
    }
1278461
public JsonWriter property(String key, Object value) throws IOException {
      Preconditions.checkArgument(!inArray(), "Cannot write a property inside an array.");
      writeName(key);
      value(value);
      return this;
   }
120775
public JsonWriter endArray() throws IOException {
      checkAndPop(JsonTokenType.BEGIN_ARRAY);
      popIf(JsonTokenType.NAME);
      writer.endArray();
      return this;
   }
1317325
public JsonWriter value(double value) {
        startValue();

        final long i = (long) value;
        if (value == (double) i) {
            writer.print(i);
        } else {
            writer.print(value);
        }
        return this;
    }
502222
public String toJson()
      throws IOException {
    StringWriter writer = new StringWriter();
    try (JsonGenerator generator = jsonFactory.createJsonGenerator(writer)
        .setCodec(objectMapper)) {
      toJsonUtf8(generator);
    }

    return writer.toString();
  }
1066605
protected JsonWriter writeObject(Object object) throws IOException {
      if (object == null) {
         nullValue();
      } else if (object instanceof JsonSerializable) {
         JsonSerializable structuredSerializable = Cast.as(object);
         if (object instanceof JsonArraySerializable) {
            beginArray();
         } else {
            beginObject();
         }
         structuredSerializable.toJson(this);
         if (object instanceof JsonArraySerializable) {
            endArray();
         } else {
            endObject();
         }
      } else if (object instanceof Number) {
         value(Cast.<Number>as(object));
      } else if (object instanceof String) {
         value(Cast.<String>as(object));
      } else if (object instanceof Boolean) {
         value(Cast.<Boolean>as(object).toString());
      } else if (object instanceof Enum) {
         value(Cast.<Enum>as(object).name());
      } else if (object instanceof EnumValue) {
         value(Cast.<EnumValue>as(object).name());
      } else if (object instanceof Map) {
         value(Cast.<Map<String, ?>>as(object));
      } else if (object.getClass().isArray()) {
         value(Cast.<Object[]>as(object));
      } else if (object instanceof Multimap) {
         value(Cast.<Multimap<String, ?>>as(object).asMap());
      } else if (object instanceof Counter) {
         value(Cast.<Counter<String>>as(object).asMap());
      } else if (object instanceof Iterable) {
         value(Cast.<Iterable>as(object));
      } else if (object instanceof Iterator) {
         value(Cast.<Iterator>as(object));
      } else {
         value(Convert.convert(object, String.class));
      }
      return this;
   }
1092755
public JsonWriter value(Number number) throws IOException {
      Preconditions.checkArgument(inArray() || writeStack.peek() == JsonTokenType.NAME,
                                  "Expecting an array or a name, but found " + writeStack.peek());
      popIf(JsonTokenType.NAME);
      writer.value(number);
      return this;
   }
414209
private JsonWriter open(JsonScope empty, String openBracket) throws IOException {
        beforeValue(true);
        stack.add(empty);
        out.write(openBracket);
        return this;
    }
815692
public JsonWriter value(String value) throws IOException {
        if (value == null) {
            return nullValue();
        }
        beforeValue(false);
        string(value);
        return this;
    }
871236
private JsonToken startParsing() throws IOException {
    JsonToken currentToken = getCurrentToken();
    // token is null at start, so get next token
    if (currentToken == null) {
      currentToken = nextToken();
    }
    Preconditions.checkArgument(currentToken != null, "no JSON input found");
    return currentToken;
  }
731720
public Serializer writeArray(JSONArray value) throws IOException {
        if (null == value) return writeNull();

        // write header
        writeRawString("[");
        indentPush();

        for (Iterator iter=value.iterator(); iter.hasNext(); )
        {
            Object element = iter.next();
            if (!JSONObject.isValidObject(element)) throw new IOException("attempting to serialize array with an invalid element: '" + value + "'");

            newLine();
            indent();
            write(element);

            if (iter.hasNext()) writeRawString(",");
        }

        // write trailer
        indentPop();
        newLine();
        indent();
        writeRawString("]");

        return this;
    }
1069013
public JSONObject toJson() throws IOException {
    String base64 = new Zip().zip(getDirectory());
    Map<String, String> map = ImmutableMap.of(
      "className", this.getClass().getName(),
      BASE64_JSON_KEY, base64);
    
    return new JSONObject(map);
  }
688535
public byte[] toCompressedJSON() throws IOException {
        // Wrap a GZIPOuputStream around a ByteArrayOuputStream.
        ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
        GZIPOutputStream gzipOut = new GZIPOutputStream(bytesOut);
        
        // Wrap the GZIPOutputStream with an OutputStreamWriter that convers JSON Unicode
        // text to bytes using UTF-8.
        OutputStreamWriter writer = new OutputStreamWriter(gzipOut, Utils.UTF8_CHARSET);
        
        // Create a JSONEmitter that will write its output to the writer above and generate
        // the JSON output.
        JSONEmitter json = new JSONEmitter(writer);
        json.startDocument();
        toJSON(json);
        json.endDocument();
        
        // Ensure the output stream is flushed and the GZIP is finished, then the output
        // buffer is complete.
        writer.flush();
        gzipOut.finish();
        return bytesOut.toByteArray();
    }