0
當發送一個大的pojo時,我想檢查字節變化,而不是詳細的結構差異。也許序列化並散列在內存中的pojo,但可以在Android設備上失敗。任何想法都會是鞭打。也許應該穿過它的風格。比較大的本地gson和遠程gson
OUT
outputStreamWriter = new OutputStreamWriter(out, "UTF-8");
jsonWriter = new JsonWriter(outputStreamWriter);
jsonWriter.setIndent(" ");
jsonWriter.setIndent("\t");
jsonWriter. beginArray();
mygson.toJson(largeTestPojo, LargeTestPojo.class, jsonWriter);
jsonWriter.endArray();
jsonWriter.flush();
IN
InputStreamReader isr = new InputStreamReader(in, "UTF-8");
StatsTypeAdapterFactory stats = new StatsTypeAdapterFactory();
Gson gson = new GsonBuilder().registerTypeAdapterFactory(stats).create();
jsonReader = new JsonReader(isr);
jsonReader. beginArray();
largeTestPojo= gson.fromJson(jsonReader, LargeTestPojo.class);
jsonReader.endArray();