code: public static void jsonValue(JsonWriter writer, Object value) throws IOException {
          if (value == null) {
              writer.nullValue();
          } else {
              if (value instanceof Map) {
                  jsonMap(writer, (Map<String, Object>) value);
              } else if (value instanceof Collection) {
                  writer.beginArray();
                  for (Object val : ((Collection) value)) {
                      jsonValue(writer, val);
                  }
                  writer.endArray();
              } else if (value instanceof Object[]) {
                  writer.beginArray();
                  for (Object val : ((Object[]) value)) {
                      jsonValue(writer, val);
                  }
                  writer.endArray();
              } else if (value instanceof Boolean) {
                  writer.value((Boolean) value);
              } else if (value instanceof Long) {
                  writer.value((Long) value);
              } else if (value instanceof Double) {
                  writer.value((Double) value);
              } else if (value instanceof Number) {
                  writer.value((Number) value);
              } else {
                  writer.value(value.toString());
              }
          }
      }
docs: Transforms an object into a JSON object (stream).