當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonWriter.beginObject方法代碼示例

本文整理匯總了Java中android.util.JsonWriter.beginObject方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonWriter.beginObject方法的具體用法?Java JsonWriter.beginObject怎麽用?Java JsonWriter.beginObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.util.JsonWriter的用法示例。


在下文中一共展示了JsonWriter.beginObject方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: writeActions

import android.util.JsonWriter; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.KITKAT)
private void writeActions(JsonWriter writer, Notification notification) throws IOException {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        return;
    }

    if (notification.actions != null) {
        Log.d(TAG, "writing action");
        writer.name("actions");
        writer.beginArray();
        for (Notification.Action a : notification.actions) {
            Log.d(TAG, "writing action : " + a.title.toString());
            writer.beginObject();
            writer.name("title").value(a.title.toString());
            writer.endObject();
        }
        writer.endArray();
    }
}
 
開發者ID:RomascuAndrei,項目名稱:BTNotifierAndroid,代碼行數:20,代碼來源:Message.java

示例2: listToJsonStr

import android.util.JsonWriter; //導入方法依賴的package包/類
public static String listToJsonStr(final List<Object> list) {
    if (list == null || list.isEmpty()) {
        return EMPTY_STRING;
    }
    final StringWriter sw = new StringWriter();
    final JsonWriter writer = new JsonWriter(sw);
    try {
        writer.beginArray();
        for (final Object o : list) {
            writer.beginObject();
            if (o instanceof Integer) {
                writer.name(INTEGER_CLASS_NAME).value((Integer)o);
            } else if (o instanceof String) {
                writer.name(STRING_CLASS_NAME).value((String)o);
            }
            writer.endObject();
        }
        writer.endArray();
        return sw.toString();
    } catch (final IOException e) {
    } finally {
        close(writer);
    }
    return EMPTY_STRING;
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:26,代碼來源:JsonUtils.java

示例3: onOpen

import android.util.JsonWriter; //導入方法依賴的package包/類
@Override
public void onOpen(ServerHandshake handshakedata) {

    StringWriter stringWriter = new StringWriter();
    JsonWriter writer = new JsonWriter(stringWriter);

    try {
        writer.beginObject();
        writer.name("event").value("onOpen");
        writer.name("resourceId").value(this.id);
        writer.endObject();
    } catch (IOException e) {
        e.printStackTrace();
    }

    this.callback(PluginResult.Status.OK, stringWriter.toString());
}
 
開發者ID:flynetworks,項目名稱:cordova-websocket-clientcert,代碼行數:18,代碼來源:WebSocketClient.java

示例4: onMessage

import android.util.JsonWriter; //導入方法依賴的package包/類
@Override
public void onMessage(String message) {

    StringWriter stringWriter = new StringWriter();
    JsonWriter writer = new JsonWriter(stringWriter);

    try {
        writer.beginObject();
        writer.name("event").value("onMessage");
        writer.name("message").value(message);
        writer.endObject();
    } catch (IOException e) {
        e.printStackTrace();
    }

    this.callback(PluginResult.Status.OK, stringWriter.toString());
}
 
開發者ID:flynetworks,項目名稱:cordova-websocket-clientcert,代碼行數:18,代碼來源:WebSocketClient.java

示例5: onClose

import android.util.JsonWriter; //導入方法依賴的package包/類
@Override
public void onClose(int code, String reason, boolean remote) {
    StringWriter stringWriter = new StringWriter();
    JsonWriter writer = new JsonWriter(stringWriter);

    try {
        writer.beginObject();
        writer.name("event").value("onClose");
        writer.name("code").value(code);
        writer.name("reason").value(reason);
        writer.name("remote").value(remote);
        writer.endObject();
    } catch (IOException e) {
        e.printStackTrace();
    }

    this.callback(PluginResult.Status.OK, stringWriter.toString());
}
 
開發者ID:flynetworks,項目名稱:cordova-websocket-clientcert,代碼行數:19,代碼來源:WebSocketClient.java

示例6: onError

import android.util.JsonWriter; //導入方法依賴的package包/類
@Override
public void onError(Exception ex) {
    StringWriter stringWriter = new StringWriter();
    JsonWriter writer = new JsonWriter(stringWriter);

    try {
        writer.beginObject();
        writer.name("event").value("onError");

        if (ex instanceof UnresolvedAddressException) {
            writer.name("errorCode").value("ERR_NAME_NOT_RESOLVED");
            writer.name("errorMessage").value("Unable to resolve address. Please check the url and your network connection");
        } else {
            writer.name("errorCode").value("ERR_NAME_UNKNOWN");
            writer.name("errorMessage").value("Unknown error was thrown");
        }

        writer.endObject();
    } catch (IOException e) {
        e.printStackTrace();
    }

    this.callback(PluginResult.Status.OK, stringWriter.toString());
}
 
開發者ID:flynetworks,項目名稱:cordova-websocket-clientcert,代碼行數:25,代碼來源:WebSocketClient.java

示例7: writeEvent

import android.util.JsonWriter; //導入方法依賴的package包/類
private void writeEvent(@NonNull final JsonWriter writer, @NonNull final String[] types,
                        @NonNull final String[] foodTypes, @NonNull final String[] drinkTypes,
                        @NonNull Event event) throws IOException {
    String subType;
    switch (event.getType()) {
        case Event.TYPE_FOOD:
            subType = foodTypes[event.getSubType()];
            break;
        case Event.TYPE_DRINK:
            subType = drinkTypes[event.getSubType()];
            break;
        default:
            subType = "";
    }

    writer.beginObject();
    writer.name(KEY_ID).value(event.getID());
    writer.name(KEY_DATE).value(event.getDate().toString(DatabaseHelper.DB_DATE_FORMATTER));
    writer.name(KEY_TIME).value(event.getTime().toString(DatabaseHelper.DB_TIME_FORMATTER));
    writer.name(KEY_TYPE).value(types[event.getType()]);
    writer.name(KEY_TITLE).value(subType);
    writer.name(KEY_DESC).value(event.getDescription());
    writer.endObject();
}
 
開發者ID:canyapan,項目名稱:DietDiaryApp,代碼行數:25,代碼來源:DriveBackupService.java

示例8: writeParty

import android.util.JsonWriter; //導入方法依賴的package包/類
/**
 * Write passed party to passed Json writer
 * @param writer
 * @param party
 * @throws IOException
 */
public void writeParty(JsonWriter writer, Party party) throws IOException {
    //print open curly braces {
    writer.beginObject();

    //print keys and values
    writer.name(KEY_ID).value(party.getId());
    writer.name(KEY_NAME).value(party.getName());
    writer.name(KEY_PHONE).value(party.getPhone());
    writer.name(KEY_DEBIT).value(party.getDebitTotal());
    writer.name(KEY_CREDIT).value(party.getCreditTotal());
    writer.name(KEY_TYPE).value(party.getType().toString());
    writer.name(KEY_PICTURE).value(party.getPicturePath());

    //print journals
    writeJournals(writer, party.getId());

    //print close curly braces }
    writer.endObject();
}
 
開發者ID:ndhunju,項目名稱:dailyJournal,代碼行數:26,代碼來源:JsonConverterStream.java

示例9: writeToJSON

import android.util.JsonWriter; //導入方法依賴的package包/類
private void writeToJSON(OutputStream out, Date date, Location loc) throws IOException {
    FileOutputStream outputStream;
    JsonWriter writer = new JsonWriter(new OutputStreamWriter(out, "UTF-8"));
    writer.setIndent("  ");
    writer.beginArray();

    writer.beginObject();
    writer.name("Date").value(date.toString());

    writer.name("Location");
    writer.beginArray();
    writer.value(loc.getLatitude());
    writer.value(loc.getLongitude());
    writer.endArray();

    writer.endObject();
    writer.close();
}
 
開發者ID:alexdao,項目名稱:footstep,代碼行數:19,代碼來源:MainActivity.java

示例10: toJSON

import android.util.JsonWriter; //導入方法依賴的package包/類
public String toJSON(Context context) {
    StringWriter out = new StringWriter();
    JsonWriter writer = new JsonWriter(out);

    try {
        writer.beginObject();
        writer.name("event").value(event);

        writer.name("eventItems");
        writer.beginArray();

        if (type == SendType.SMS) {
            toJsonSMessage(context, writer, sMessage);
        } else if (type == SendType.NOTI) {
            for (StatusBarNotification sbn : notifications) {
                toJsonNotification(context, writer, sbn);
            }
        }
        writer.endArray();
        writer.endObject();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return out.toString();
}
 
開發者ID:holylobster,項目名稱:nuntius-android,代碼行數:27,代碼來源:Message.java

示例11: serializeRepresentation

import android.util.JsonWriter; //導入方法依賴的package包/類
@Override
public void serializeRepresentation(JsonWriter writer) throws IOException {
    writer.beginObject();
    int len = mBands.size();
    int count = 0;

    for (int i = 0; i < len; i++) {
        Band point = mBands.get(i);
        if (point.mask) {
            continue;
        }
        writer.name(LINE_NAME + count);
        count++;
        writer.beginArray();
        writer.value(point.xPos1);
        writer.value(point.yPos1);
        writer.value(point.xPos2);
        writer.value(point.yPos2);
        writer.value(point.brightness);
        writer.value(point.contrast);
        writer.value(point.saturation);
        writer.endArray();
    }
    writer.endObject();
}
 
開發者ID:asm-products,項目名稱:nexus-gallery,代碼行數:26,代碼來源:FilterGradRepresentation.java

示例12: serializeRepresentation

import android.util.JsonWriter; //導入方法依賴的package包/類
@Override
public void serializeRepresentation(JsonWriter writer) throws IOException {
    writer.beginObject();
    {
        writer.name(NAME_TAG);
        writer.value(getName());
        for (int i = 0; i < mSplines.length; i++) {
            writer.name(SERIALIZATION_NAME + i);
            writer.beginArray();
            int nop = mSplines[i].getNbPoints();
            for (int j = 0; j < nop; j++) {
                ControlPoint p = mSplines[i].getPoint(j);
                writer.beginArray();
                writer.value(p.x);
                writer.value(p.y);
                writer.endArray();
            }
            writer.endArray();
        }

    }
    writer.endObject();
}
 
開發者ID:asm-products,項目名稱:nexus-gallery,代碼行數:24,代碼來源:FilterCurvesRepresentation.java

示例13: save

import android.util.JsonWriter; //導入方法依賴的package包/類
@Override
public void save() {
    try {
        OutputStream out = SIAApp.SIA_APP.openFileOutput("news", Context.MODE_PRIVATE);
        JsonWriter writer = new JsonWriter(new OutputStreamWriter(out));

        writer.setIndent("  ");
        writer.beginArray();
        for(Entry s : this) {
            writer.beginObject();

            writer.name("id").value(s.id);
            writer.name("date").value(s.date.getTime());
            writer.name("topic").value(s.topic);
            writer.name("source").value(s.source);
            writer.name("title").value(s.title);
            writer.name("text").value(s.text);

            writer.endObject();
        }
        writer.endArray();
        writer.close();
    } catch(Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:Cedgetec,項目名稱:SchulinfoApp-android,代碼行數:27,代碼來源:News.java

示例14: writeTransition

import android.util.JsonWriter; //導入方法依賴的package包/類
/**
 * @param writer
 * @param transition the ChapterTransition object to be written in JSON
 * @throws IOException
 */
public static void writeTransition(JsonWriter writer, ChapterTransition transition) throws IOException {
    writer.beginObject();
    writer.name("type").value("transition");
    writer.name("time").value(transition.getTime());
    writer.name("item_position").value(transition.getItemPosition());
    writer.name("child_id").value(transition.getChildID());
    writer.name("id").value(transition.getAnchorViewID());
    writer.name("message").value(transition.getMessage());
    writer.name("message_res_id").value(transition.getMessageResID());
    writer.name("graphic_res_id").value(transition.getGraphicResID());
    writer.name("is_action_bar_item").value(transition.isInActionBar());
    writer.name("x_offset").value(transition.getWidthRatio());
    writer.name("y_offset").value(transition.getHeightRatio());
    writer.name("text_color").value(transition.getTextColor());
    writer.name("text_background_color").value(transition.getTextBackgroundColor());
    writer.name("text_size").value(transition.getTextSize());
    writer.name("text_background_transparent").value(transition.hasTransparentBackground());
    writer.name("animation").value(transition.getAnimation());
    writer.endObject();
}
 
開發者ID:fuzz-productions,項目名稱:LimeLight,代碼行數:26,代碼來源:JSONTool.java

示例15: writeAct

import android.util.JsonWriter; //導入方法依賴的package包/類
/**
 * @param writer
 * @param act the act object to be written into JSON
 * @throws IOException
 */
public static void writeAct(JsonWriter writer, Act act) throws IOException {
    writer.beginObject();
    writer.name("id").value(act.getAnchorViewID());
    writer.name("message").value(act.getMessage());
    writer.name("message_res_id").value(act.getMessageResID());
    writer.name("graphic_res_id").value(act.getGraphicResID());
    writer.name("is_action_bar_item").value(act.isInActionBar());
    writer.name("x_offset").value(act.getWidthRatio());
    writer.name("y_offset").value(act.getHeightRatio());
    writer.name("text_color").value(act.getTextColor());
    writer.name("text_background_color").value(act.getTextBackgroundColor());
    writer.name("text_size").value(act.getTextSize());
    writer.name("text_background_transparent").value(act.hasTransparentBackground());
    writer.name("animation").value(act.getAnimation());
    writer.name("activity_name").value(act.getActivityName());
    writer.endObject();
}
 
開發者ID:fuzz-productions,項目名稱:LimeLight,代碼行數:23,代碼來源:JSONTool.java


注:本文中的android.util.JsonWriter.beginObject方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。