22
33import java .io .File ;
44import java .io .IOException ;
5+ import java .lang .reflect .Type ;
56import java .nio .file .Files ;
67
8+ import com .google .gson .*;
79import org .glassfish .jersey .client .ClientProperties ;
810import org .glassfish .jersey .client .JerseyClient ;
911import org .glassfish .jersey .client .JerseyClientBuilder ;
2224import com .creatubbles .api .response .gallery .CreateUserGalleryResponse ;
2325import com .creatubbles .api .response .user .UserProfileResponse ;
2426import com .creatubbles .api .util .EndPoints ;
25- import com .google .gson .Gson ;
26- import com .google .gson .GsonBuilder ;
2727
2828
2929@ SuppressWarnings ("deprecation" )
@@ -39,6 +39,7 @@ public class CreatubblesAPI {
3939 .registerTypeAdapter (GetCreationsResponse .class , new GetCreationsResponse ())
4040 .registerTypeAdapter (CreateCreationResponse .class , new CreateCreationResponse ())
4141 .registerTypeAdapter (CreationsUploadsResponse .class , new CreationsUploadsResponse ())
42+ .registerTypeAdapter (String .class , new StringAdapter ())
4243 .create ();
4344
4445 public final static JerseyClient CLIENT = JerseyClientBuilder
@@ -83,4 +84,14 @@ public static void main(String[] args) throws IOException {
8384 System .out .println ("-Finish-" );
8485 }
8586
87+ static class StringAdapter implements JsonDeserializer <String > {
88+
89+ public String deserialize (JsonElement json , Type typeOfT ,
90+ JsonDeserializationContext context )
91+ throws JsonParseException {
92+ String asString = json .getAsJsonPrimitive ().getAsString ();
93+ return asString != null && asString .isEmpty () ? null : asString ;
94+ }
95+ }
96+
8697}
0 commit comments