本文整理匯總了Java中android.util.JsonWriter.name方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonWriter.name方法的具體用法?Java JsonWriter.name怎麽用?Java JsonWriter.name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.util.JsonWriter
的用法示例。
在下文中一共展示了JsonWriter.name方法的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: writeJson
import android.util.JsonWriter; //導入方法依賴的package包/類
public void writeJson(JsonWriter writer, String name) {
int numFilters = mFilters.size();
try {
writer.beginObject();
for (int i = 0; i < numFilters; i++) {
FilterRepresentation filter = mFilters.get(i);
if (filter instanceof FilterUserPresetRepresentation) {
continue;
}
String sname = filter.getSerializationName();
if (DEBUG) {
Log.v(LOGTAG, "Serialization: " + sname);
if (sname == null) {
Log.v(LOGTAG, "Serialization name null for filter: " + filter);
}
}
writer.name(sname);
filter.serializeRepresentation(writer);
}
writer.endObject();
} catch (IOException e) {
Log.e(LOGTAG,"Error encoding JASON",e);
}
}
示例3: serializeRepresentation
import android.util.JsonWriter; //導入方法依賴的package包/類
@Override
public void serializeRepresentation(JsonWriter writer) throws IOException {
writer.beginObject();
int len = mBands.size();
int count = 0;
for (int i = 0; i < len; i++) {
Band point = mBands.get(i);
if (point.mask) {
continue;
}
writer.name(LINE_NAME + count);
count++;
writer.beginArray();
writer.value(point.xPos1);
writer.value(point.yPos1);
writer.value(point.xPos2);
writer.value(point.yPos2);
writer.value(point.brightness);
writer.value(point.contrast);
writer.value(point.saturation);
writer.endArray();
}
writer.endObject();
}
示例4: 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();
}
示例5: 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();
}
示例6: 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();
}
示例7: 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();
}
示例8: 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();
}
示例9: writeJson
import android.util.JsonWriter; //導入方法依賴的package包/類
static void writeJson(final SharedPreferences prefs, final JsonWriter jsonWriter)
throws IOException {
jsonWriter.beginObject();
for (Map.Entry<String,?> entry : prefs.getAll().entrySet()) {
jsonWriter.name(entry.getKey());
final Object innerValue = entry.getValue();
if (innerValue == null) {
jsonWriter.nullValue();
} else if (innerValue instanceof Boolean) {
jsonWriter.value((Boolean) innerValue);
} else if (innerValue instanceof Number) {
jsonWriter.value((Number) innerValue);
} else {
jsonWriter.value(innerValue.toString());
}
}
jsonWriter.endObject();
}
示例10: mapToWriter
import android.util.JsonWriter; //導入方法依賴的package包/類
/** Encode the given {@link Map} into the {@link JsonWriter}. */
private static void mapToWriter(Map<?, ?> map, JsonWriter writer) throws IOException {
writer.beginObject();
for (Map.Entry<?, ?> entry : map.entrySet()) {
writer.name(String.valueOf(entry.getKey()));
writeValue(entry.getValue(), writer);
}
writer.endObject();
}
示例11: testJsonWriter
import android.util.JsonWriter; //導入方法依賴的package包/類
@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());
}
示例12: serializeRepresentation
import android.util.JsonWriter; //導入方法依賴的package包/類
public void serializeRepresentation(JsonWriter writer) throws IOException {
writer.beginObject();
{
writer.name("size");
writer.value(mParamSize.getValue());
writer.name("radius");
writer.value(mParamRadius.getValue());
writer.name("color");
writer.value(mParamColor.getValue());
}
writer.endObject();
}
示例13: serializeRepresentation
import android.util.JsonWriter; //導入方法依賴的package包/類
@Override
public void serializeRepresentation(JsonWriter writer) throws IOException {
writer.beginObject();
int len = mDrawing.size();
int count = 0;
float[] mPosition = new float[2];
float[] mTan = new float[2];
PathMeasure mPathMeasure = new PathMeasure();
for (int i = 0; i < len; i++) {
writer.name(SERIAL_PATH + i);
writer.beginObject();
StrokeData mark = mDrawing.get(i);
writer.name(SERIAL_COLOR).value(mark.mColor);
writer.name(SERIAL_RADIUS).value(mark.mRadius);
writer.name(SERIAL_TYPE).value(mark.mType);
writer.name(SERIAL_POINTS_COUNT).value(mark.noPoints);
writer.name(SERIAL_POINTS);
writer.beginArray();
int npoints = mark.noPoints * 2;
for (int j = 0; j < npoints; j++) {
writer.value(mark.mPoints[j]);
}
writer.endArray();
writer.endObject();
}
writer.endObject();
}
示例14: serializeRepresentation
import android.util.JsonWriter; //導入方法依賴的package包/類
/**
* Method must "beginObject()" add its info and "endObject()"
* @param writer
* @throws IOException
*/
public void serializeRepresentation(JsonWriter writer) throws IOException {
writer.beginObject();
{
String[][] rep = serializeRepresentation();
for (int k = 0; k < rep.length; k++) {
writer.name(rep[k][0]);
writer.value(rep[k][1]);
}
}
writer.endObject();
}
示例15: serializeDetails
import android.util.JsonWriter; //導入方法依賴的package包/類
private static String serializeDetails(
PaymentItem total, @Nullable List<PaymentItem> displayItems) {
StringWriter stringWriter = new StringWriter();
JsonWriter json = new JsonWriter(stringWriter);
try {
// details {{{
json.beginObject();
// total {{{
json.name("total");
serializePaymentItem(total, json);
// }}} total
// displayitems {{{
if (displayItems != null) {
json.name("displayItems").beginArray();
for (int i = 0; i < displayItems.size(); i++) {
serializePaymentItem(displayItems.get(i), json);
}
json.endArray();
}
// }}} displayItems
json.endObject();
// }}} details
} catch (IOException e) {
return null;
}
return stringWriter.toString();
}