code: private Serializer write(Object object) throws IOException {
          if (null == object) return writeNull();
          if (object instanceof Number) return writeNumber((Number) object);
          if (object instanceof String) return writeString((String) object);
          if (object instanceof Boolean) return writeBoolean((Boolean) object);
          if (object instanceof JSONObject) return writeObject((JSONObject) object);
          if (object instanceof JSONArray) return writeArray((JSONArray) object);
  
          throw new IOException("Attempting to serialize unserializable object: '" + object + "'");
      }
docs: Method to write out a generic JSON type.
  @param object The JSON compatible object to serialize.
  @throws IOException Thrown if an error occurs during write, or if a nonJSON compatible Java object is passed..