Java Code Examples for android.util.JsonWriter#flush()
The following examples show how to use
android.util.JsonWriter#flush() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GeneralPreferenceFragment.java From NClientV2 with Apache License 2.0 | 6 votes |
private String getDataSettings(Context context)throws IOException{ String[]names=new String[]{"Settings","ScrapedTags"}; StringWriter sw=new StringWriter(); JsonWriter writer=new JsonWriter(sw); writer.setIndent("\t"); writer.beginObject(); for(String name:names) processSharedFromName(writer,context,name); writer.endObject(); writer.flush(); String settings=sw.toString(); writer.close(); LogUtility.d(settings); return settings; }
Example 2
Source File: Gallery.java From NClientV2 with Apache License 2.0 | 5 votes |
public void jsonWrite(Writer ww)throws IOException{ //images aren't saved JsonWriter writer=new JsonWriter(ww); writer.beginObject(); writer.name("id").value(getId()); writer.name("media_id").value(getMediaId()); writer.name("upload_date").value(getUploadDate().getTime()/1000); writer.name("num_favorites").value(getFavoriteCount()); toJsonTitle(writer); toJsonTags(writer); writer.endObject(); writer.flush(); }
Example 3
Source File: SimpleTest.java From unmock-plugin with Apache License 2.0 | 5 votes |
@Test public void testJsonWriter() throws Exception { StringWriter sw = new StringWriter(); JsonWriter jw = new JsonWriter(sw); jw.beginObject(); jw.name("test"); jw.value("world"); jw.endObject(); jw.flush(); assertEquals("{\"test\":\"world\"}", sw.toString()); }
Example 4
Source File: SimpleTest.java From unmock-plugin with Apache License 2.0 | 5 votes |
@Test public void testJsonWriter() throws Exception { StringWriter sw = new StringWriter(); JsonWriter jw = new JsonWriter(sw); jw.beginObject(); jw.name("test"); jw.value("world"); jw.endObject(); jw.flush(); assertEquals("{\"test\":\"world\"}", sw.toString()); }