ContentItem.java
1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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;
}
}