package com.hjx.parent.api; import com.google.gson.Gson; import com.google.gson.annotations.SerializedName; public class ContentItem { public static final String TYPE_TEXT = "text"; public static final String TYPE_IMAGE = "image_url"; public ContentItem() { } public ContentItem(String type, String text) { this.type = type; this.text = text; } public ContentItem(String type, ContentImage imageUrl) { this.type = type; this.imageUrl = imageUrl; } public String type; public String text; @SerializedName("image_url") public ContentImage imageUrl; public static class ContentImage { public String url; } private static final Gson gson = new Gson(); static ContentItem reSerialize(Object any) { if (any == null) return null; try { String json = gson.toJson(any); ContentItem it = gson.fromJson(json, ContentItem.class); return it; } catch (Throwable t) { t.printStackTrace(); } return null; } }