本文整理匯總了Java中android.util.JsonWriter.setIndent方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonWriter.setIndent方法的具體用法?Java JsonWriter.setIndent怎麽用?Java JsonWriter.setIndent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.util.JsonWriter
的用法示例。
在下文中一共展示了JsonWriter.setIndent方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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();
}
示例2: 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();
}
}
示例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();
}
}
示例4: toJson
import android.util.JsonWriter; //導入方法依賴的package包/類
/**
* Serializes the map into it's json representation into the provided {@link Writer}. If you want
* to retrieve the json as a string, use {@link #toJson(Map)} instead.
*/
public void toJson(Map<?, ?> map, Writer writer) throws IOException {
if (map == null) {
throw new IllegalArgumentException("map == null");
}
if (writer == null) {
throw new IllegalArgumentException("writer == null");
}
JsonWriter jsonWriter = new JsonWriter(writer);
jsonWriter.setLenient(isLenient);
if (prettyPrint) {
jsonWriter.setIndent(" ");
}
try {
mapToWriter(map, jsonWriter);
} finally {
jsonWriter.close();
}
}
示例5: toJson
import android.util.JsonWriter; //導入方法依賴的package包/類
/**
* Serializes the map into it's json representation into the provided {@link Writer}. If you want
* to retrieve the json as a string, use {@link #toJson(Map)} instead.
*/
public void toJson(Map<?, ?> map, Writer writer) throws IOException {
if (map == null) {
throw new IllegalArgumentException("map == null");
}
if (writer == null) {
throw new IllegalArgumentException("writer == null");
}
JsonWriter jsonWriter = new JsonWriter(writer);
jsonWriter.setLenient(isLenient);
if (prettyPrint) {
jsonWriter.setIndent(" ");
}
try {
mapToWriter(map, jsonWriter);
} finally {
jsonWriter.close();
}
}
示例6: 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();
}
}
示例7: start
import android.util.JsonWriter; //導入方法依賴的package包/類
@Override
protected void start(OutputStreamWriter outputStream, Resources resources) throws IOException {
writer = new JsonWriter(outputStream);
writer.setIndent(" ");
writer.beginObject();
writer.name("App").value("DietDiaryApp");
writer.name("Ver").value(1);
writer.name("Events").beginArray();
types = resources.getStringArray(R.array.spinner_event_types);
foodTypes = resources.getStringArray(R.array.spinner_event_food_types);
drinkTypes = resources.getStringArray(R.array.spinner_event_drink_types);
}
示例8: BackupExporter
import android.util.JsonWriter; //導入方法依賴的package包/類
public BackupExporter(OutputStream out) {
OutputStreamWriter streamWriter;
try {
streamWriter = new OutputStreamWriter(out, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new AssertionError(e);
}
mJsonWriter = new JsonWriter(streamWriter);
mJsonWriter.setIndent("\t");
}
示例9: saveFilter
import android.util.JsonWriter; //導入方法依賴的package包/類
public static void saveFilter(Filter.FilterList list) {
try {
OutputStream out = SIAApp.SIA_APP.openFileOutput("ggfilterV2", Context.MODE_PRIVATE);
JsonWriter writer = new JsonWriter(new OutputStreamWriter(out));
writer.setIndent(" ");
writer.beginArray();
for(Filter.IncludingFilter inc : list.including) {
writer.beginObject();
writer.name("type").value(inc.getType().toString());
writer.name("filter").value(inc.getFilter());
writer.name("excluding").beginArray();
for (Filter.ExcludingFilter f : inc.excluding) {
writer.beginObject();
writer.name("type").value(f.getType().toString());
writer.name("filter").value(f.getFilter());
writer.name("contains").value(f.contains);
writer.endObject();
}
writer.endArray();
writer.endObject();
}
writer.endArray();
writer.close();
} catch(Exception e) {
e.printStackTrace();
}
}
示例10: save
import android.util.JsonWriter; //導入方法依賴的package包/類
public void save() {
Log.d("ggvp", "Saving exams");
try {
OutputStream out = SIAApp.SIA_APP.openFileOutput("exams", Context.MODE_PRIVATE);
JsonWriter writer = new JsonWriter(new OutputStreamWriter(out));
writer.setIndent(" ");
writer.beginArray();
for(ExamItem s : this) {
writer.beginObject();
writer.name("date").value(s.date.getTime());
writer.name("clazz").value(s.clazz);
writer.name("lesson").value(s.lesson);
writer.name("length").value(s.length);
writer.name("subject").value(s.subject);
writer.name("teacher").value(s.teacher);
writer.name("selected").value(s.selected);
writer.endObject();
}
writer.endArray();
writer.close();
} catch(Exception e) {
e.printStackTrace();
}
}
示例11: saveList
import android.util.JsonWriter; //導入方法依賴的package包/類
public static void saveList() {
try {
OutputStream out = SIAApp.SIA_APP.openFileOutput("schools", Context.MODE_PRIVATE);
JsonWriter writer = new JsonWriter(new OutputStreamWriter(out));
writer.setIndent(" ");
writer.beginArray();
for(School s : LIST) {
writer.beginObject();
writer.name("sid").value(s.sid);
writer.name("name").value(s.name);
writer.name("authRequired").value(s.loginNeeded);
writer.name("website").value(s.website);
writer.name("image").value(s.image);
writer.name("theme").value(s.themeName);
writer.name("city").value(s.city);
writer.name("users").value(s.users);
writer.name("fragments").beginArray();
for(FragmentData frag : s.fragments) {
writer.beginObject();
writer.name("type").value(frag.type.toString());
writer.name("data").value(frag.getParams());
if(frag.type == FragmentData.FragmentType.PDF) {
writer.name("name").value(frag.name);
switch(frag.icon) {
case R.drawable.ic_mensa:
writer.name("icon").value("mensa");
break;
case R.drawable.ic_substitution:
writer.name("icon").value("subst");
break;
case R.drawable.ic_exam:
writer.name("icon").value("exam");
break;
case R.drawable.ic_news:
writer.name("icon").value("news");
break;
}
}
writer.endObject();
}
writer.endArray();
writer.endObject();
}
writer.endArray();
writer.close();
} catch(Exception e) {
Log.e("ggvp", e.toString());
e.printStackTrace();
}
}
示例12: writeJSON
import android.util.JsonWriter; //導入方法依賴的package包/類
/**
* Entry point writer method that starts the call of other writer methods.
*
* @param outputStream
* @param book
* @throws IOException
*/
public static void writeJSON(OutputStream outputStream, Book book) throws IOException {
JsonWriter writer = new JsonWriter(new OutputStreamWriter(outputStream, "UTF-8"));
writer.setIndent(" ");
writeBook(writer, book);
writer.close();
}