Example usage for android.util JsonToken END_OBJECT

List of usage examples for android.util JsonToken END_OBJECT

Introduction

In this page you can find the example usage for android.util JsonToken END_OBJECT.

Prototype

JsonToken END_OBJECT

To view the source code for android.util JsonToken END_OBJECT.

Click Source Link

Document

The closing of a JSON object.

Usage

From source file:com.thingsee.tracker.REST.KiiBucketRequestAsyncTask.java

private JSONObject readSingleData(JsonReader jsonReader) throws IOException, JSONException {
    JSONObject jsonObject = new JSONObject();
    jsonReader.beginObject();//from www  .j  ava2s  .  co  m
    JsonToken token;
    do {
        String name = jsonReader.nextName();
        if ("sId".equals(name)) {
            jsonObject.put("sId", jsonReader.nextString());
        } else if ("val".equals(name)) {
            jsonObject.put("val", jsonReader.nextDouble());
        } else if ("ts".equals(name)) {
            jsonObject.put("ts", jsonReader.nextLong());
        } else if ("_owner".equals(name)) {
            jsonObject.put("_owner", jsonReader.nextString());
        }

        token = jsonReader.peek();
    } while (token != null && !token.equals(JsonToken.END_OBJECT));
    jsonReader.endObject();
    return jsonObject;
}