From 9ead79ec352a50d44f9eefb2496d4471733215e8 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Tue, 12 Mar 2013 10:56:52 +0200 Subject: [PATCH] Improve JSON parsing Command arguments are now represented as JSON arrays, and the JSON parsing code uses less memory. Previous versions can no longer receive commands, since they expect command arguments in the old arg0, arg1, ... form. --- src/ro/ieval/fonbot/PollServerAsyncTask.java | 21 ++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/ro/ieval/fonbot/PollServerAsyncTask.java b/src/ro/ieval/fonbot/PollServerAsyncTask.java index 1be09c3..07c014b 100644 --- a/src/ro/ieval/fonbot/PollServerAsyncTask.java +++ b/src/ro/ieval/fonbot/PollServerAsyncTask.java @@ -109,24 +109,29 @@ public final class PollServerAsyncTask extends AsyncTask list=new ArrayList(); + + final JSONArray array; + { + final byte[] buf=new byte[4096*1024]; + conn.getInputStream().read(buf); + array=new JSONArray(new String(buf)); + } + for(int i=0;i