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


Java JsonWriter.setIndent方法代碼示例

本文整理匯總了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();
}
 
開發者ID:alexdao,項目名稱:footstep,代碼行數:19,代碼來源:MainActivity.java

示例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();
    }
}
 
開發者ID:Cedgetec,項目名稱:SchulinfoApp-android,代碼行數:27,代碼來源:News.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包/類
/**
 * 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();
  }
}
 
開發者ID:segmentio,項目名稱:cartographer,代碼行數:24,代碼來源:Cartographer.java

示例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();
  }
}
 
開發者ID:segmentio,項目名稱:analytics-android,代碼行數:24,代碼來源:Cartographer.java

示例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();
	}
}
 
開發者ID:Nordskog,項目名稱:ClassHunter,代碼行數:41,代碼來源:ProfileCache.java

示例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);
}
 
開發者ID:canyapan,項目名稱:DietDiaryApp,代碼行數:15,代碼來源:BackupToJSON.java

示例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");
}
 
開發者ID:apsun,項目名稱:NekoSMS,代碼行數:11,代碼來源:BackupExporter.java

示例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();
    }
}
 
開發者ID:Cedgetec,項目名稱:SchulinfoApp-android,代碼行數:28,代碼來源:FilterActivity.java

示例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();
    }
}
 
開發者ID:Cedgetec,項目名稱:SchulinfoApp-android,代碼行數:29,代碼來源:Exams.java

示例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();
    }
}
 
開發者ID:Cedgetec,項目名稱:SchulinfoApp-android,代碼行數:55,代碼來源:School.java

示例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();
}
 
開發者ID:fuzz-productions,項目名稱:LimeLight,代碼行數:14,代碼來源:JSONTool.java


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