本文整理匯總了Java中android.util.JsonWriter.endObject方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonWriter.endObject方法的具體用法?Java JsonWriter.endObject怎麽用?Java JsonWriter.endObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.util.JsonWriter
的用法示例。
在下文中一共展示了JsonWriter.endObject方法的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();
}
}
示例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;
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例7: writeSettings
import android.util.JsonWriter; //導入方法依賴的package包/類
private void writeSettings(@NonNull final JsonWriter writer) throws IOException {
// Write settings
writer.name("Settings").beginObject();
if (mSharedPreferences.contains(KEY_GENERAL_CLOCK_MODE_STRING)) {
writer.name(KEY_GENERAL_CLOCK_MODE_STRING)
.value(mSharedPreferences.getString(KEY_GENERAL_CLOCK_MODE_STRING, "-1"));
}
if (mSharedPreferences.contains(KEY_NOTIFICATIONS_ACTIVE_BOOL)) {
writer.name(KEY_NOTIFICATIONS_ACTIVE_BOOL)
.value(mSharedPreferences.getBoolean(KEY_NOTIFICATIONS_ACTIVE_BOOL, true));
}
if (mSharedPreferences.contains(KEY_NOTIFICATIONS_DAILY_REMAINDER_BOOL)) {
writer.name(KEY_NOTIFICATIONS_DAILY_REMAINDER_BOOL)
.value(mSharedPreferences.getBoolean(KEY_NOTIFICATIONS_DAILY_REMAINDER_BOOL, true));
}
if (mSharedPreferences.contains(KEY_NOTIFICATIONS_DAILY_REMAINDER_TIME_STRING)) {
writer.name(KEY_NOTIFICATIONS_DAILY_REMAINDER_TIME_STRING)
.value(mSharedPreferences.getString(KEY_NOTIFICATIONS_DAILY_REMAINDER_TIME_STRING, "19:00"));
}
writer.endObject();
}
示例8: 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();
}
示例9: save
import android.util.JsonWriter; //導入方法依賴的package包/類
public void save() {
try {
OutputStream out = SIAApp.SIA_APP.openFileOutput("mensa", Context.MODE_PRIVATE);
JsonWriter writer = new JsonWriter(new OutputStreamWriter(out));
writer.setIndent(" ");
writer.beginArray();
for(MensaItem s : this) {
writer.beginObject();
writer.name("id").value(s.id);
writer.name("date").value(s.date);
writer.name("meal").value(s.meal);
writer.name("garnish").value(s.garnish);
writer.name("dessert").value(s.dessert);
writer.name("vegetarian").value(s.vegetarian);
writer.name("image").value(s.image);
writer.endObject();
}
writer.endArray();
writer.close();
} catch(Exception e) {
e.printStackTrace();
}
}
示例10: 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();
}
}
示例11: 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();
}
示例12: serializeRepresentation
import android.util.JsonWriter; //導入方法依賴的package包/類
@Override
public void serializeRepresentation(JsonWriter writer) throws IOException {
writer.beginObject();
writer.name(ARGS);
writer.beginArray();
writer.value(getValue(MODE_MASTER));
writer.value(getValue(MODE_RED));
writer.value(getValue(MODE_YELLOW));
writer.value(getValue(MODE_GREEN));
writer.value(getValue(MODE_CYAN));
writer.value(getValue(MODE_BLUE));
writer.value(getValue(MODE_MAGENTA));
writer.endArray();
writer.endObject();
}
示例13: 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();
}
示例14: serializeRepresentation
import android.util.JsonWriter; //導入方法依賴的package包/類
@Override
public void serializeRepresentation(JsonWriter writer) throws IOException {
writer.beginObject();
writer.name(ELLIPSE);
writer.beginArray();
writer.value(mCenterX);
writer.value(mCenterY);
writer.value(mRadiusX);
writer.value(mRadiusY);
writer.endArray();
writer.name(ARGS);
writer.beginArray();
writer.value(mParamVignette.getValue());
writer.value(mParamExposure.getValue());
writer.value(mParamSaturation.getValue());
writer.value(mParamContrast.getValue());
writer.value(mParamFalloff.getValue());
writer.endArray();
writer.endObject();
}
示例15: 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();
}