ios - 将 json 对象从 iphone 发送到 java servlet 的时间太长

标签 ios json http google-app-engine servlets

我们正在开发一个 iPhone 应用程序,它将用户所在位置的 json 字符串发送到部署在 Google 应用程序引擎上的 Web 应用程序 (JAVA)。我们使用 htpp 请求来发送这些字符串。我们的问题是字符串有时很大,这需要很长时间。还有其他方法吗?

最佳答案

您可以压缩 JSON。这是 GAE 的代码片段:

JSONObject json = new JSONObject(uncompress(Base64.decode(encodedJSONData)));

这是解压缩方法:

protected String uncompress(byte[] compressedData) throws IOException {
    StringBuffer data = new StringBuffer();
    GZIPInputStream stream = new GZIPInputStream(new ByteArrayInputStream(compressedData));
    BufferedReader br = new BufferedReader(new InputStreamReader(stream));
    String line;
    while ((line = br.readLine()) != null) {
        data.append(line);
    }
    return data.toString();
}

关于ios - 将 json 对象从 iphone 发送到 java servlet 的时间太长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8909761/

相关文章:

javascript - 在 Aurelia.io 示例中读取 json 时出错

javascript - 使用 Angularjs 循环范围

jquery - 打开浏览器打印的application/json类型

java - 在Java中验证Http请求的方法?

ios - 有没有办法在保持同一页面的同时从 UIPageViewController 中更改标签文本?

ios - 以编程方式从 UIBarButtonItem 继续

ios - 屏幕显示太慢

ios - 连续计算实际日期和 future 日期之间的时间

ruby - 在 Ruby/Sinatra 中解码 Facebook 的签名请求

php - 正在发送 POST header ,但未在服务器上接收到