Java 类org.json.JSONWriter 实例源码
项目:telegramBotUtilities
文件:InputVenueMessageContent.java
@Override
public JSONObject toJSONObject() {
JSONWriter w = new JSONStringer();
w.object();
w.key("latitude");
w.value(latitude);
w.key("longitude");
w.value(longitude);
w.key("title");
w.value(title);
w.key("address");
w.value(address);
w.key("foursquare_id");
w.value(foursquare_id);
w.endObject();
return new JSONObject(w.toString());
}
项目:storr
文件:LXP.java
private void serializeFieldsToJSON(JSONWriter writer) throws JSONException {
for( int i = 0; i < getMetaData().getFieldCount(); i++ ) {
String key = getMetaData().getFieldName( i );
writer.key(key);
Object value = field_storage[ i ];
if (value instanceof ArrayList) {
writer.array();
for (Object o : (List) value) {
if (o instanceof LXP ) {
writeReference(writer, (LXP) o);
} else {
writeSimpleValue(writer, o);
}
}
writer.endArray();
} else {
writeSimpleValue(writer, value);
}
}
}
项目:abhot
文件:JsonFormatter.java
@Override
public void format(Writer writer, Iterable<String> iterable) throws FormatterException
{
checkNotNull(writer);
checkNotNull(iterable);
try
{
JSONWriter jsonWriter = new JSONWriter(writer);
jsonWriter.object().key("results").array();
for (String string : iterable)
{
jsonWriter.value(string);
}
jsonWriter.endArray().endObject();
}
catch (JSONException e)
{
throw new FormatterException(e);
}
}
项目:abhot
文件:TypeGroupByResult.java
@Override
public String toJson() throws FormatterException
{
StringWriter stringWriter = new StringWriter();
JSONWriter writer = new JSONWriter(stringWriter);
try
{
writer.object();
writer.key("name").value("type");
writer.key("type").value(m_type);
writer.endObject();
}
catch (JSONException e)
{
throw new FormatterException(e);
}
return stringWriter.toString();
}
项目:telegramBotUtilities
文件:ReplyKeyboardMarkup.java
public String toJSONString() {
JSONWriter s = new JSONStringer();
s.object();
s.key("keyboard");
s.array();
for (int i = 0; i < keyboard.length; i++) {
s.array();
for (int j = 0; j < keyboard[i].length; j++) {
s.value(keyboard[i][j]);
}
s.endArray();
}
s.endArray();
s.key("resize_keyboard");
s.value(resize_keyboard);
s.key("one_time_keyboard");
s.value(one_time_keyboard);
s.key("selective");
s.value(selective);
s.endObject();
return s.toString();
}
项目:modeller
文件:Profile.java
/**
* serialize.
*
* @param jsonWriter JSONWriter
* @throws JSONException exception
*/
public void serialize(final JSONWriter jsonWriter) throws JSONException {
final JSONWriter writer = jsonWriter.object().key(Profile.FIELD_NAME).value(getName());
final String orgStringer = getOrganization().serialize();
final String fromContact = getSendFromContact().serialize();
final String toContact = getSendToContact().serialize();
final String localCustomFields = seralizeFields(this.getCustomFields().values());
final String localStandardFields = seralizeFields(this.getStandardFields().values());
writer.key(FIELD_ORGANIZATION).value(new JSONObject(new JSONTokener(orgStringer)));
writer.key(FIELD_SENDFROM).value(new JSONObject(new JSONTokener(fromContact)));
writer.key(FIELD_SENDTO).value(new JSONObject(new JSONTokener(toContact)));
writer.key(FIELD_CUSTOM_INFO).value(new JSONObject(new JSONTokener(localCustomFields)));
writer.key(FIELD_STANDARD_INFO).value(new JSONObject(new JSONTokener(localStandardFields)));
writer.endObject();
}
项目:alfresco-version-by-name
文件:AutoVersionByNameBehaviour.java
private void postActivityUpdated(NodeRef nodeRef) {
SiteInfo siteInfo = siteService.getSite(nodeRef);
String jsonActivityData = "";
try {
JSONWriter jsonWriter = new JSONStringer().object();
jsonWriter.key("title").value(nodeService.getProperty(nodeRef, ContentModel.PROP_NAME).toString());
jsonWriter.key("nodeRef").value(nodeRef.toString());
StringBuilder sb = new StringBuilder("document-details?nodeRef=");
sb.append(URLEncoder.encode(nodeRef.toString(), "UTF-8"));
jsonWriter.key("page").value(sb.toString());
jsonActivityData = jsonWriter.endObject().toString();
} catch (Exception e) {
throw new RuntimeException(e);
}
activityService.postActivity(
ActivityType.FILE_UPDATED,
(siteInfo == null ? null : siteInfo.getShortName()),
(siteInfo == null ? null : SiteService.DOCUMENT_LIBRARY),
jsonActivityData);
}
项目:singular-server
文件:SingularToastrHelper.java
private String toStringJson(ToastrSettings settings) {
JSONWriter jsonWriter = new JSONStringer().object();
for (StringTextValue<?> textValue : settings.asSet()) {
String name = textValue.getName();
name = name.substring(name.lastIndexOf('.') + 1);
Object value;
if (textValue.getType() == StringTextType.ENUM) {
value = ((StringTextValue<? extends ValueEnum>) textValue).getValue().getValue();
} else {
value = textValue.getValue();
}
jsonWriter.key(name).value(value);
}
return jsonWriter.endObject().toString();
}
项目:ForgedUI-Eclipse
文件:BasicCodeGenerator.java
@Override
protected void handleSplitWindowProperties(TitaniumUIBaseElement element, JSONWriter propWriter, String fqdn) throws JSONException {
if(element instanceof SplitWindow){
String masterView = ((SplitWindow)element).getMasterView();
String detailView = ((SplitWindow)element).getDetailView();
propWriter.keyUnescaped("masterView");
if(masterView != null && !masterView.isEmpty())
propWriter.valueUnescaped(masterView);
else
propWriter.valueUnescaped("null");
propWriter.keyUnescaped("detailView");
if(detailView != null && !detailView.isEmpty())
propWriter.valueUnescaped(detailView);
else
propWriter.valueUnescaped("null");
}
}
项目:mylyn-redmine-connector
文件:Transport.java
public void addUserToGroup(int userId, int groupId) throws RedmineException {
logger.debug("adding user " + userId + " to group " + groupId + "...");
URI uri = getURIConfigurator().getChildObjectsURI(Group.class, Integer.toString(groupId), User.class);
HttpPost httpPost = new HttpPost(uri);
final StringWriter writer = new StringWriter();
final JSONWriter jsonWriter = new JSONWriter(writer);
try {
jsonWriter.object().key("user_id").value(userId).endObject();
} catch (JSONException e) {
throw new RedmineInternalError("Unexpected exception", e);
}
String body = writer.toString();
setEntity(httpPost, body);
String response = send(httpPost);
logger.debug(response);
}
项目:mylyn-redmine-connector
文件:Transport.java
public void addWatcherToIssue(int watcherId, int issueId) throws RedmineException {
logger.debug("adding watcher " + watcherId + " to issue " + issueId + "...");
URI uri = getURIConfigurator().getChildObjectsURI(Issue.class, Integer.toString(issueId), Watcher.class);
HttpPost httpPost = new HttpPost(uri);
final StringWriter writer = new StringWriter();
final JSONWriter jsonWriter = new JSONWriter(writer);
try {
jsonWriter.object().key("user_id").value(watcherId).endObject();
} catch (JSONException e) {
throw new RedmineInternalError("Unexpected exception", e);
}
String body = writer.toString();
setEntity(httpPost, body);
String response = send(httpPost);
logger.debug(response);
}
项目:mylyn-redmine-connector
文件:RedmineJSONBuilder.java
/**
* Converts object to a "simple" json.
*
* @param tag
* object tag.
* @param object
* object to convert.
* @param writer
* object writer.
* @return object String representation.
* @throws RedmineInternalError
* if conversion fails.
*/
public static <T> String toSimpleJSON(String tag, T object,
JsonObjectWriter<T> writer) throws RedmineInternalError {
final StringWriter swriter = new StringWriter();
final JSONWriter jsWriter = new JSONWriter(swriter);
try {
jsWriter.object();
jsWriter.key(tag);
jsWriter.object();
writer.write(jsWriter, object);
jsWriter.endObject();
jsWriter.endObject();
} catch (JSONException e) {
throw new RedmineInternalError("Unexpected JSONException", e);
}
return swriter.toString();
}
项目:mylyn-redmine-connector
文件:RedmineJSONBuilder.java
public static void writeUser(User user, final JSONWriter writer)
throws JSONException {
JsonOutput.addIfNotNull(writer, "id", user.getId());
JsonOutput.addIfNotNull(writer, "login", user.getLogin());
JsonOutput.addIfNotNull(writer, "password", user.getPassword());
JsonOutput.addIfNotNull(writer, "firstname", user.getFirstName());
JsonOutput.addIfNotNull(writer, "lastname", user.getLastName());
JsonOutput.addIfNotNull(writer, "name", user.getFullName());
JsonOutput.addIfNotNull(writer, "mail", user.getMail());
JsonOutput.addIfNotNull(writer, "auth_source_id", user.getAuthSourceId());
JsonOutput.addIfNotNull(writer, "status", user.getStatus());
addIfNotNullFull(writer, "created_on", user.getCreatedOn());
addIfNotNullFull(writer, "last_login_on", user.getLastLoginOn());
writeCustomFields(writer, user.getCustomFields());
}
项目:mylyn-redmine-connector
文件:RedmineJSONBuilder.java
public static void writeMembership(JSONWriter writer, Membership membership)
throws JSONException {
if (membership.getUser() != null) {
JsonOutput.addIfNotNull(writer, "user_id", membership.getUser().getId());
}
if (membership.getGroup() != null) {
JsonOutput.addIfNotNull(writer, "group_id", membership.getGroup().getId());
}
if (membership.getRoles() != null) {
writer.key("role_ids");
writer.array();
for (Role role : membership.getRoles()) {
writer.value(role.getId().longValue());
}
writer.endArray();
}
}
项目:mylyn-redmine-connector
文件:RedmineJSONBuilder.java
private static void writeCustomFields(JSONWriter writer,
Collection<CustomField> customFields) throws JSONException {
if (customFields == null || customFields.isEmpty()) {
return;
}
writer.key("custom_field_values").object();
for (CustomField field : customFields) {
// see https://github.com/taskadapter/redmine-java-api/issues/54
Object valueToWrite;
if (field.isMultiple()) {
valueToWrite = field.getValues();
} else {
valueToWrite = field.getValue();
}
writer.key(Integer.toString(field.getId())).value(valueToWrite);
}
writer.endObject();
}
项目:Contraptions
文件:ContraptionManager.java
/**
* Saves all the current Contraptions to a file
*
* @param file File Contraptions are saved to
*/
public void saveContraptions(File file) {
try {
ContraptionsPlugin.toConsole("Saving Contraptions...");
FileOutputStream fileOutputStream = new FileOutputStream(file);
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(fileOutputStream));
JSONWriter jsonWriter = new JSONWriter(bufferedWriter);
jsonWriter.array();
Iterator<Contraption> contraptions = dao.iterator();
while (contraptions.hasNext()) {
jsonWriter.value(contraptions.next().save());
}
jsonWriter.endArray();
bufferedWriter.flush();
fileOutputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
项目:perfcharts
文件:ZabbixDownloader.java
private static JSONObject callRPC(String url, String method,
JSONObject params, String auth, int id)
throws MalformedURLException, IOException, ZabbixAPIException {
LOGGER.info("JSON RPC Request begins: " + method);
HttpURLConnection http = (HttpURLConnection) new URL(url)
.openConnection();
http.setDoOutput(true);
http.setDoInput(true);
http.setUseCaches(false);
http.setConnectTimeout(1000 * 60);
http.setRequestMethod("POST");
http.setRequestProperty("Connection", "Close");
http.setRequestProperty("Content-Type", "application/json-rpc");
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
http.getOutputStream()));
JSONWriter jsonWriter = new JSONWriter(writer);
jsonWriter.object().key("jsonrpc").value("2.0").key("method")
.value(method).key("id").value(id).key("auth").value(auth)
.key("params").value(params).endObject();
writer.flush();
JSONObject r = new JSONObject(new JSONTokener(new BufferedReader(
new InputStreamReader(http.getInputStream()))));
http.disconnect();
LOGGER.info("JSON RPC Request ends: " + method);
return r;
}
项目:manami
文件:JsonExporter.java
public boolean exportList(final List<Anime> list, final Path file) {
try (final PrintWriter printWriter = new PrintWriter(file.toFile())) {
final JSONWriter writer = new JSONWriter(printWriter);
writer.array();
writer.array();
for (final Anime element : list) {
writer.object().key("title").value(element.getTitle()).key("type").value(element.getTypeAsString()).key("episodes").value(element.getEpisodes()).key("infoLink").value(element.getInfoLink()).key("location").value(element.getLocation())
.endObject();
}
writer.endArray();
writer.endArray();
printWriter.flush();
} catch (final FileNotFoundException e) {
log.error("An error occurred while trying to export the list to JSON: ", e);
return false;
}
return true;
}
项目:eeplat-social-api
文件:JSONWriter.java
/**
* Append a value.
* @param s A string value.
* @return this
* @throws JSONException If the value is out of sequence.
*/
private JSONWriter append(String s) throws JSONException {
if (s == null) {
throw new JSONException("Null pointer");
}
if (this.mode == 'o' || this.mode == 'a') {
try {
if (this.comma && this.mode == 'a') {
this.writer.write(',');
}
this.writer.write(s);
} catch (IOException e) {
throw new JSONException(e);
}
if (this.mode == 'o') {
this.mode = 'k';
}
this.comma = true;
return this;
}
throw new JSONException("Value out of sequence.");
}
项目:eeplat-social-api
文件:JSONWriter.java
/**
* Append a key. The key will be associated with the next value. In an
* object, every value must be preceded by a key.
* @param s A key string.
* @return this
* @throws JSONException If the key is out of place. For example, keys
* do not belong in arrays or if the key is null.
*/
public JSONWriter key(String s) throws JSONException {
if (s == null) {
throw new JSONException("Null key.");
}
if (this.mode == 'k') {
try {
if (this.comma) {
this.writer.write(',');
}
stack[top - 1].putOnce(s, Boolean.TRUE);
this.writer.write(JSONObject.quote(s));
this.writer.write(':');
this.comma = false;
this.mode = 'o';
return this;
} catch (IOException e) {
throw new JSONException(e);
}
}
throw new JSONException("Misplaced key.");
}
项目:storr
文件:StaticLXP.java
public String toString() {
StringWriter writer = new StringWriter();
try {
serializeToJSON(new JSONWriter(writer));
} catch (Exception e) {
throw new RuntimeException(e);
}
return writer.toString();
}
项目:storr
文件:LXP.java
private void writeReference( JSONWriter writer, LXP value ) {
try {
IStoreReference reference = value.getThisRef();
writer.value(reference.toString() );
} catch (PersistentObjectException e) {
throw new JSONException( "Cannot serialise reference" );
}
}
项目:storr
文件:LXP.java
private void writeSimpleValue(JSONWriter writer, Object value) throws JSONException {
if (value instanceof Double) {
writer.value(((Double) (value)).doubleValue());
} else if (value instanceof Integer) {
writer.value(((Integer) (value)).intValue());
} else if (value instanceof Boolean) {
writer.value(((Boolean) (value)).booleanValue());
} else if (value instanceof Long) {
writer.value(((Long) (value)).longValue());
} else {
writer.value(value); // default is to write a string
}
}
项目:storr
文件:DynamicLXP.java
public String toString() {
StringWriter writer = new StringWriter();
try {
serializeToJSON(new JSONWriter(writer));
} catch (Exception e) {
throw new RuntimeException(e);
}
return writer.toString();
}
项目:storr
文件:DirectoryBackedBucket.java
private void writeData(LXP record_to_write, Path filepath) throws BucketException {
try (Writer writer = Files.newBufferedWriter(filepath, FileManipulation.FILE_CHARSET)) { // auto close and exception
record_to_write.serializeToJSON(new JSONWriter(writer), this);
object_cache.put(record_to_write.getId(), record_to_write); // Putting this call here ensures that all records that are in a bucket and loaded are in the cache
} catch (IOException | JSONException e) {
throw new BucketException(e);
}
}
项目:gitplex-mit
文件:AjaxSettings.java
void toJson(JSONWriter writer) throws JSONException {
writer.object();
Json.writeFunction(writer, "data", data);
Json.writeObject(writer, "dataType", dataType);
Json.writeObject(writer, "quietMillis", quietMillis);
Json.writeFunction(writer, "results", results);
Json.writeObject(writer, "url", url);
Json.writeObject(writer, "traditional", traditional);
writer.endObject();
}
项目:abhot
文件:TagGroupByResult.java
@Override
public String toJson() throws FormatterException
{
StringWriter stringWriter = new StringWriter();
JSONWriter writer = new JSONWriter(stringWriter);
try
{
writer.object();
writer.key("name").value("tag");
writer.key("tags").array();
for (String name : groupBy.getTagNames())
{
writer.value(name);
}
writer.endArray();
writer.key("group").object();
for (String tagName : tagResults.keySet())
{
writer.key(tagName).value(tagResults.get(tagName));
}
writer.endObject();
writer.endObject();
}
catch (JSONException e)
{
throw new FormatterException(e);
}
return stringWriter.toString();
}
项目:abhot
文件:ValueGroupBy.java
@Override
public GroupByResult getGroupByResult(final int id)
{
return new GroupByResult()
{
@Override
public String toJson() throws FormatterException
{
StringWriter stringWriter = new StringWriter();
try
{
JSONWriter writer = new JSONWriter(stringWriter);
writer.object();
writer.key("name").value("value");
writer.key("range_size").value(rangeSize);
writer.key("group").object();
writer.key("group_number").value(id);
writer.endObject();
writer.endObject();
}
catch (JSONException e)
{
throw new FormatterException(e);
}
return stringWriter.toString();
}
};
}
项目:abhot
文件:BinGroupBy.java
@Override
public GroupByResult getGroupByResult(final int id)
{
return new GroupByResult()
{
@Override
public String toJson() throws FormatterException
{
StringWriter stringWriter = new StringWriter();
try
{
JSONWriter writer = new JSONWriter(stringWriter);
writer.object();
writer.key("name").value("bin");
writer.key("bins").value(bins);
writer.key("group").object();
writer.key("bin_number").value(id);
writer.endObject();
writer.endObject();
}
catch (JSONException e)
{
throw new FormatterException(e);
}
return stringWriter.toString();
}
};
}
项目:abhot
文件:TimeGroupBy.java
@Override
public GroupByResult getGroupByResult(final int id)
{
return new GroupByResult()
{
@Override
public String toJson() throws FormatterException
{
StringWriter stringWriter = new StringWriter();
try
{
JSONWriter writer = new JSONWriter(stringWriter);
writer.object();
writer.key("name").value("time");
writer.key("range_size").object();
writer.key("value").value(rangeSize.getValue());
writer.key("unit").value(rangeSize.getUnit().toString());
writer.endObject();
writer.key("group_count").value(groupCount);
writer.key("group").object();
writer.key("group_number").value(id);
writer.endObject();
writer.endObject();
}
catch (JSONException e)
{
throw new FormatterException(e);
}
return stringWriter.toString();
}
};
}
项目:abhot
文件:DoubleDataPoint.java
@Override
public void writeValueToJson(JSONWriter writer) throws JSONException
{
//in kairosdb 1.1.3 is a bug : m_value != m_value???
if (Double.isInfinite(m_value))
throw new IllegalStateException("not a number or Infinity:" + m_value + " data point=" + this);
writer.value(m_value);
}
项目:abhot
文件:ComplexDataPoint.java
@Override
public void writeValueToJson(JSONWriter writer) throws JSONException
{
writer.object();
writer.key("real").value(m_real);
writer.key("imaginary").value(m_imaginary);
writer.endObject();
}
项目:telegramBotUtilities
文件:InlineQueryResultVenue.java
public JSONObject toJSONObject() {
JSONWriter w = new JSONStringer();
w.object();
w.key("type");
w.value(getType());
w.key("id");
w.value(getId());
w.key("longitude");
w.value(location.getLongitude());
w.key("latitude");
w.value(location.getLatitude());
w.key("title");
w.value(getTitle());
if (address != null) {
w.key("address");
w.value(address);
}
if (foursquare_id != null) {
w.key("foursquare_id");
w.value(foursquare_id);
}
if (reply_markup != null) {
w.key("reply_markup");
w.value(reply_markup.toJSONString());
}
if (getInput_message_content() != null) {
w.key("input_message_content");
w.value(getInput_message_content().toJSONObject());
}
if (getThumb_url() != null) {
w.key("thumb_url");
w.value(getThumb_url());
}
w.key("thumb_width");
w.value(thumb_width);
w.key("thumb_height");
w.value(thumb_height);
w.endObject();
return new JSONObject(w.toString());
}
项目:telegramBotUtilities
文件:InputContactMessageContent.java
@Override
public JSONObject toJSONObject() {
JSONWriter w = new JSONStringer();
w.object();
w.key("phone_number");
w.value(phone_number);
w.key("first_name");
w.value(first_name);
w.key("last_name");
w.value(last_name);
w.endObject();
return new JSONObject(w.toString());
}
项目:telegramBotUtilities
文件:InputTextMessageContent.java
@Override
public JSONObject toJSONObject() {
JSONWriter w = new JSONStringer();
w.object();
w.key("message_text");
w.value(message_text);
w.key("parse_mode");
w.value(parse_mode);
w.key("disable_web_page_preview");
w.value(disable_web_page_preview);
w.endObject();
return new JSONObject(w.toString());
}
项目:telegramBotUtilities
文件:InputLocationMessageContent.java
@Override
public JSONObject toJSONObject() {
JSONWriter w = new JSONStringer();
w.object();
w.key("latitude");
w.value(latitude);
w.key("longitude");
w.value(longitude);
w.endObject();
return new JSONObject(w.toString());
}
项目:telegramBotUtilities
文件:ReplyKeyboardHide.java
public String toJSONString() {
JSONWriter s = new JSONStringer();
s.object();
s.key("hide_keyboard");
s.value(hide_keyboard);
s.key("selective");
s.value(selective);
s.endObject();
return s.toString();
}
项目:telegramBotUtilities
文件:InlineQueryResultMpeg4Gif.java
@Override
public JSONObject toJSONObject() {
JSONWriter writer = new JSONStringer();
writer.object();
writer.key("type");
writer.value(getType());
writer.key("id");
writer.value(getId());
if (getTitle() != null) {
writer.key("title");
writer.value(getTitle());
}
if (getInput_message_content() != null) {
writer.key("input_message_content");
writer.value(getInput_message_content().toJSONObject());
}
writer.key("mpeg4_url");
writer.value(getMpeg4_url());
if (caption != null) {
writer.key("caption");
writer.value(getCaption());
}
writer.key("thumb_url");
writer.value(getThumb_url());
writer.key("mpeg4_width");
writer.value(getMpeg4_width());
writer.key("mpeg4_height");
writer.value(getMpeg4_height());
writer.endObject();
return new JSONObject(writer.toString());
}
项目:telegramBotUtilities
文件:TelegramBot.java
/**
* Answers an inline query.
*
* @param inline_query_id
* @param results
* An array of {@link InlineQueryResult}.
* @return
* <ul>
* <li>true if operation is successful</li>
* <li>false if operation is unsuccessful</li>
* </ul>
* @throws IOException
*/
public boolean answerInlineQuery(String inline_query_id, InlineQueryResult[] results) throws IOException {
// creating the JSON-Serialized array
JSONWriter writer = new JSONStringer();
writer.array();
for (int i = 0; i < results.length; i++) {
writer.value(results[i].toJSONObject());
}
writer.endArray();
URL updateUrl = new URL(url + "/answerInlineQuery?inline_query_id=" + inline_query_id + "&results="
+ URLEncoder.encode(writer.toString(), "utf-8"));
String temp, response = "";
System.out.println(updateUrl.toString());
BufferedReader in = new BufferedReader(new InputStreamReader(updateUrl.openStream()));
// create the results string
while ((temp = in.readLine()) != null) {
response += temp;
}
in.close();
// if the "ok" parameter in JSON results is set to false, it throws an
// exception
return new JSONObject(response).getBoolean("ok") == true ? true : false;
}
项目:telegramBotUtilities
文件:InlineQueryResultPhoto.java
@Override
public JSONObject toJSONObject() {
JSONWriter writer = new JSONStringer();
writer.object();
writer.key("type");
writer.value(getType());
writer.key("id");
writer.value(getId());
if (getTitle() != null) {
writer.key("title");
writer.value(getTitle());
}
if (getInput_message_content() != null) {
writer.key("input_message_content");
writer.value(getInput_message_content().toJSONObject());
}
writer.key("photo_url");
writer.value(getPhoto_url());
if (caption != null) {
writer.key("caption");
writer.value(getCaption());
}
if (getDescription() != null) {
writer.key("description");
writer.value(getDescription());
}
writer.key("thumb_url");
writer.value(getThumb_url());
writer.key("photo_width");
writer.value(getPhoto_width());
writer.key("photo_height");
writer.value(getPhoto_height());
writer.endObject();
return new JSONObject(writer.toString());
}