本文整理匯總了Java中android.util.JsonWriter.value方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonWriter.value方法的具體用法?Java JsonWriter.value怎麽用?Java JsonWriter.value使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.util.JsonWriter
的用法示例。
在下文中一共展示了JsonWriter.value方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: writeValue
import android.util.JsonWriter; //導入方法依賴的package包/類
/**
* Writes the given {@link Object} to the {@link JsonWriter}.
*
* @throws IOException
*/
private static void writeValue(Object value, JsonWriter writer) throws IOException {
if (value == null) {
writer.nullValue();
} else if (value instanceof Number) {
writer.value((Number) value);
} else if (value instanceof Boolean) {
writer.value((Boolean) value);
} else if (value instanceof List) {
listToWriter((List) value, writer);
} else if (value instanceof Map) {
mapToWriter((Map) value, writer);
} else {
writer.value(String.valueOf(value));
}
}
示例2: 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();
}
示例3: 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();
}
示例4: 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();
}
示例5: 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();
}
示例6: 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();
}
示例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: 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);
}
}
示例9: writeValue
import android.util.JsonWriter; //導入方法依賴的package包/類
/**
* Writes the given {@link Object} to the {@link JsonWriter}.
*
* @throws IOException
*/
private static void writeValue(Object value, JsonWriter writer) throws IOException {
if (value == null) {
writer.nullValue();
} else if (value instanceof Number) {
writer.value((Number) value);
} else if (value instanceof Boolean) {
writer.value((Boolean) value);
} else if (value instanceof List) {
listToWriter((List) value, writer);
} else if (value instanceof Map) {
mapToWriter((Map) value, writer);
} else if (value.getClass().isArray()) {
arrayToWriter(value, writer);
} else {
writer.value(String.valueOf(value));
}
}
示例10: 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();
}
示例11: 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();
}
示例12: 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());
}
示例13: 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();
}
示例14: 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();
}
示例15: 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();
}