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


Java JsonWriter.endArray方法代碼示例

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


在下文中一共展示了JsonWriter.endArray方法的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: 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();
    }
}
 
開發者ID:Cedgetec,項目名稱:SchulinfoApp-android,代碼行數:27,代碼來源:Mensa.java

示例4: 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

示例5: serializeStringCollection

import android.util.JsonWriter; //導入方法依賴的package包/類
/**
 * A generic serializer for string collections.
 *
 * @param collection Collection to serialize
 * @param <C>        A concrete collection class, e.g. {@code ArrayList<String>}.
 * @return JSON representation of the string collection.
 */
@NonNull
public static <C extends Collection<String>> String serializeStringCollection(@NonNull C collection) {
    StringWriter writer = new StringWriter();
    JsonWriter jsonWriter = new JsonWriter(writer);
    try {
        jsonWriter.beginArray();
        for (String s : collection) {
            jsonWriter.value(s);
        }
        jsonWriter.endArray();
        jsonWriter.close();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return writer.toString();
}
 
開發者ID:maskarade,項目名稱:Android-Orma,代碼行數:24,代碼來源:BuiltInSerializers.java

示例6: 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

示例7: write

import android.util.JsonWriter; //導入方法依賴的package包/類
public boolean write(final List<Person> persons,
		final OutputStream personStream) {
	final OutputStreamWriter ouw = new OutputStreamWriter(personStream,
			Charsets.UTF_8);
	final JsonWriter writer = new JsonWriter(ouw);
	try {
		writer.beginArray();
		for (final Person person : persons) {
			writePerson(person, writer);
		}
		writer.endArray();
		writer.close();
		return true;
	} catch (final IOException e) {
		Closeables.closeQuietly(writer);
	} finally {
		Closeables.closeQuietly(writer);
	}

	return false;
}
 
開發者ID:rduerig,項目名稱:nansai,代碼行數:22,代碼來源:PersonFileWriter.java

示例8: writeDisabledPlugins

import android.util.JsonWriter; //導入方法依賴的package包/類
public void writeDisabledPlugins(List<ComponentName> plugins) {
    StringWriter sw = new StringWriter(100);
    JsonWriter jw = new JsonWriter(sw);
    try {
        jw.beginArray();
        for (ComponentName cn : plugins) {
            jw.value(cn.flattenToString());
        }
        jw.endArray();
        Timber.v("Write disabled plugins=" + sw.toString());
        settings.putString(PREF_DISABLED_PLUGINS, sw.toString());
    } catch (IOException e) {
        settings.remove(PREF_DISABLED_PLUGINS);
    } finally {
        IOUtils.closeQuietly(jw);
    }
}
 
開發者ID:OpenSilk,項目名稱:Orpheus,代碼行數:18,代碼來源:PluginLoader.java

示例9: writeMessagesArray

import android.util.JsonWriter; //導入方法依賴的package包/類
public void writeMessagesArray(JsonWriter writer, List<LatLng> mesgs)
		throws IOException {
	
	writer.beginArray();
	if(null != mesgs) {
		for (LatLng message : mesgs) {
			writeMessage(writer, message);
		}
	} else {
		Log.e(TAG, "file don't contain geo data");
	}
	// record this step place
	writeThisStep(writer);

	writer.endArray();
}
 
開發者ID:youtaya,項目名稱:crabapple,代碼行數:17,代碼來源:StepRelateFragment.java

示例10: writeJson

import android.util.JsonWriter; //導入方法依賴的package包/類
static void writeJson(final SuggestedWords words, final JsonWriter jsonWriter)
        throws IOException {
    jsonWriter.beginObject();
    jsonWriter.name("typedWordValid").value(words.mTypedWordValid);
    jsonWriter.name("willAutoCorrect")
            .value(words.mWillAutoCorrect);
    jsonWriter.name("isPunctuationSuggestions")
            .value(words.mIsPunctuationSuggestions);
    jsonWriter.name("isObsoleteSuggestions").value(words.mIsObsoleteSuggestions);
    jsonWriter.name("isPrediction").value(words.mIsPrediction);
    jsonWriter.name("words");
    jsonWriter.beginArray();
    final int size = words.size();
    for (int j = 0; j < size; j++) {
        final SuggestedWordInfo wordInfo = words.getInfo(j);
        jsonWriter.value(wordInfo.toString());
    }
    jsonWriter.endArray();
    jsonWriter.endObject();
}
 
開發者ID:slightfoot,項目名稱:android-kioskime,代碼行數:21,代碼來源:JsonUtils.java

示例11: toJSON

import android.util.JsonWriter; //導入方法依賴的package包/類
void toJSON(JsonWriter writer) throws IOException {
    writer.beginObject();
    writer.name("items").beginArray();
    for (AdapterItem c : items) {
        if (!c.isPaired)
            continue;
        writer.beginObject();
        writer.name("name").value(c.name);
        writer.name("version").value(c.version);
        writer.name("versionCode").value(c.versionCode);
        writer.name("devices").value(c.devices);
        writer.name("scenes").value(c.scenes);
        writer.name("icons").value(c.icons);
        writer.name("versionCode").value(c.versionCode);
        writer.name("uniqueID").value(c.uniqueID);
        writer.name("address").value(c.address.getHostAddress());
        writer.endObject();
    }
    writer.endArray();
    writer.endObject();
}
 
開發者ID:davidgraeff,項目名稱:Android-NetPowerctrl,代碼行數:22,代碼來源:NeighbourAdapter.java

示例12: toJSON

import android.util.JsonWriter; //導入方法依賴的package包/類
public final void toJSON(JsonWriter writer) throws IOException {
    writer.beginObject();
    writer.name("ObjectType").value(getClass().getName());
    writer.name("Type").value(ui_type.ordinal());
    writer.name("Title").value(title);
    writer.name("Value").value(current_value);
    writer.name("max_value").value(max_value);
    writer.name("min_value").value(min_value);
    writer.name("Hidden").value(hidden);
    writer.name("UID").value(uid);
    if (needCredentials()) {
        if (deviceUID == null)
            throw new RuntimeException();
        writer.name("DeviceUID").value(deviceUID);
    }
    saveValue(writer);
    writer.name("Groups").beginArray();
    for (String groupUID : group_uids)
        writer.value(groupUID);
    writer.endArray();
    writer.endObject();
    writer.close();
}
 
開發者ID:davidgraeff,項目名稱:Android-NetPowerctrl,代碼行數:24,代碼來源:Executable.java

示例13: saveCache

import android.util.JsonWriter; //導入方法依賴的package包/類
/**
 * Save the cache to the specified location
 */
public static void saveCache()
{
	File file = new File(mClassCachePath + ".json");

	try
	{
		BufferedWriter out = new BufferedWriter(new FileWriter(file, false));

		JsonWriter writer = new JsonWriter(out);
		writer.setIndent("  ");
		writer.beginArray();

		for (CachedProfile item : mClassMap.values())
		{
			if (item.getUsed())
			{
				writer.beginObject();
				writer.name(TARGET_KEY).value(item.getTargetPath());
				writer.name(CLASS_KEY).value(item.getClassPath());
				writer.name(HOOK_KEY).value(item.getHookVersion());
				writer.name(MODULE_KEY).value(item.getModuleVersion());
				writer.name(SIMILARITY_KEY).value(item.getSimilarity());
				writer.endObject();
			}


		}

		writer.endArray();
		writer.close();
	}
	catch (Exception ex)
	{
		Log.e(TAG, "Failed to save profile cache");
		ex.printStackTrace();
	}
}
 
開發者ID:Nordskog,項目名稱:ClassHunter,代碼行數:41,代碼來源:ProfileCache.java

示例14: toJson

import android.util.JsonWriter; //導入方法依賴的package包/類
static void toJson(JsonWriter writer, Batch batch) throws IOException {
  writer.beginObject();

  writer.name("batch").beginArray();
  for (Message message : batch.batch()) {
    toJson(writer, message);
  }
  writer.endArray();

  writer.name("sentAt").value(Iso8601Utils.format(batch.sentAt()));

  writer.endObject();
}
 
開發者ID:f2prateek,項目名稱:segment-android,代碼行數:14,代碼來源:JsonUtils.java

示例15: listToWriter

import android.util.JsonWriter; //導入方法依賴的package包/類
/** Print the json representation of a List to the given writer. */
private static void listToWriter(List<?> list, JsonWriter writer) throws IOException {
  writer.beginArray();
  for (Object value : list) {
    writeValue(value, writer);
  }
  writer.endArray();
}
 
開發者ID:f2prateek,項目名稱:segment-android,代碼行數:9,代碼來源:JsonUtils.java


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