예제 #1
0
파일: JSON.java 프로젝트: KF5/JAVA-SDK
 public String toJSONString() {
   SerializeWriter out = new SerializeWriter();
   try {
     new JSONSerializer(out).write(this);
     return out.toString();
   } finally {
     out.close();
   }
 }
예제 #2
0
파일: JSON.java 프로젝트: KF5/JAVA-SDK
 public void writeJSONString(Appendable appendable) {
   SerializeWriter out = new SerializeWriter();
   try {
     new JSONSerializer(out).write(this);
     appendable.append(out.toString());
   } catch (IOException e) {
     throw new JSONException(e.getMessage(), e);
   } finally {
     out.close();
   }
 }
예제 #3
0
파일: JSON.java 프로젝트: KF5/JAVA-SDK
  public static final String toJSONStringZ(
      Object object, SerializeConfig mapping, SerializerFeature... features) {
    SerializeWriter out = new SerializeWriter(features);

    try {
      JSONSerializer serializer = new JSONSerializer(out, mapping);

      serializer.write(object);

      return out.toString();
    } finally {
      out.close();
    }
  }
예제 #4
0
파일: JSON.java 프로젝트: KF5/JAVA-SDK
  public static final void writeJSONStringTo(
      Object object, Writer writer, SerializerFeature... features) {
    SerializeWriter out = new SerializeWriter(writer);

    try {
      JSONSerializer serializer = new JSONSerializer(out);
      for (org.kf5.support.fastjson.serializer.SerializerFeature feature : features) {
        serializer.config(feature, true);
      }

      serializer.write(object);
    } finally {
      out.close();
    }
  }
예제 #5
0
파일: JSON.java 프로젝트: KF5/JAVA-SDK
  public static final byte[] toJSONBytes(Object object, SerializerFeature... features) {
    SerializeWriter out = new SerializeWriter();

    try {
      JSONSerializer serializer = new JSONSerializer(out);
      for (org.kf5.support.fastjson.serializer.SerializerFeature feature : features) {
        serializer.config(feature, true);
      }

      serializer.write(object);

      return out.toBytes("UTF-8");
    } finally {
      out.close();
    }
  }
예제 #6
0
파일: JSON.java 프로젝트: KF5/JAVA-SDK
  public static final String toJSONString(
      Object object, SerializeFilter[] filters, SerializerFeature... features) {
    SerializeWriter out = new SerializeWriter();

    try {
      JSONSerializer serializer = new JSONSerializer(out);
      for (org.kf5.support.fastjson.serializer.SerializerFeature feature : features) {
        serializer.config(feature, true);
      }

      serializer.config(SerializerFeature.WriteDateUseDateFormat, true);

      setFilter(serializer, filters);

      serializer.write(object);

      return out.toString();
    } finally {
      out.close();
    }
  }
예제 #7
0
파일: JSON.java 프로젝트: KF5/JAVA-SDK
  /** @since 1.1.14 */
  public static final String toJSONStringWithDateFormat(
      Object object, String dateFormat, SerializerFeature... features) {
    SerializeWriter out = new SerializeWriter();

    try {
      JSONSerializer serializer = new JSONSerializer(out);
      for (SerializerFeature feature : features) {
        serializer.config(feature, true);
      }

      serializer.config(SerializerFeature.WriteDateUseDateFormat, true);

      if (dateFormat != null) {
        serializer.setDateFormat(dateFormat);
      }

      serializer.write(object);

      return out.toString();
    } finally {
      out.close();
    }
  }