本文整理了Java中com.google.gson.JsonElement.getAsByte()
方法的一些代码示例,展示了JsonElement.getAsByte()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonElement.getAsByte()
方法的具体详情如下:
包路径:com.google.gson.JsonElement
类名称:JsonElement
方法名:getAsByte
[英]convenience method to get this element as a primitive byte value.
[中]将此元素作为基本字节值获取的简便方法。
代码示例来源:origin: searchbox-io/Jest
return (T) (Byte) id.getAsByte();
代码示例来源:origin: MovingBlocks/Terasology
@Override
public EntityData.Value deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
EntityData.Value.Builder value = EntityData.Value.newBuilder();
if (json.isJsonPrimitive()) {
extractPrimitive(value, json);
} else if (json.isJsonObject()) {
extractMap(json, context, value);
} else if (json.isJsonArray()) {
JsonArray jsonArray = json.getAsJsonArray();
TByteList byteList = new TByteArrayList();
for (JsonElement element : jsonArray) {
if (element.isJsonArray()) {
value.addValue((EntityData.Value) context.deserialize(element, EntityData.Value.class));
} else if (element.isJsonObject()) {
value.addValue((EntityData.Value) context.deserialize(element, EntityData.Value.class));
} else if (element.isJsonPrimitive()) {
extractPrimitive(value, element);
if (element.getAsJsonPrimitive().isNumber()) {
try {
byteList.add(element.getAsByte());
} catch (NumberFormatException nfe) {
byteList.add((byte) 0);
}
}
}
}
value.setBytes(ByteString.copyFrom(byteList.toArray()));
}
return value.build();
}
代码示例来源:origin: camunda/camunda-bpm-platform
@Override
public byte getAsByte() {
if (elements.size() == 1) {
return elements.get(0).getAsByte();
}
throw new IllegalStateException();
}
代码示例来源:origin: eclipse/leshan
@Override
public Byte deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
return json.getAsByte();
}
代码示例来源:origin: fenix-framework/fenix-framework
public static Byte getByteFromJson(JsonElement value) {
if (value.isJsonNull()) {
return null;
}
return value.getAsByte();
}
代码示例来源:origin: Nextdoor/bender
@Override
public byte getAsByte() {
if (elements.size() == 1) {
return elements.get(0).getAsByte();
}
throw new IllegalStateException();
}
代码示例来源:origin: fesch/CanZE
@Override
public byte getAsByte() {
if (elements.size() == 1) {
return elements.get(0).getAsByte();
}
throw new IllegalStateException();
}
代码示例来源:origin: com.google/gson
@Override
public byte getAsByte() {
if (elements.size() == 1) {
return elements.get(0).getAsByte();
}
throw new IllegalStateException();
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.gson
@Override
public byte getAsByte() {
if (elements.size() == 1) {
return elements.get(0).getAsByte();
}
throw new IllegalStateException();
}
代码示例来源:origin: eatnumber1/google-gson
@Override
public byte getAsByte() {
if (elements.size() == 1) {
return elements.get(0).getAsByte();
}
throw new IllegalStateException();
}
代码示例来源:origin: NordicSemiconductor/Android-nRF-Mesh-Library
private byte[] getKey(final JsonArray array) {
final byte[] key = new byte[array.size()];
for (int i = 0; i < array.size(); i++) {
key[i] = array.get(i).getAsByte();
}
return key;
}
代码示例来源:origin: Odoo-mobile/framework
@Override
public byte getAsByte() {
if (elements.size() == 1) {
return elements.get(0).getAsByte();
}
throw new IllegalStateException();
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
@Override
public byte getAsByte() {
if (elements.size() == 1) {
return elements.get(0).getAsByte();
}
throw new IllegalStateException();
}
代码示例来源:origin: igvteam/igv
private byte[] generateBaseQualities(JsonArray alignedQuality) {
byte[] baseQualities = new byte[alignedQuality.size()];
Iterator<JsonElement> iter = alignedQuality.iterator();
int i = 0;
while (iter.hasNext()) {
baseQualities[i++] = iter.next().getAsByte();
}
return baseQualities;
}
代码示例来源:origin: com.github.dakusui/logiaslisp
public static byte asByte(JsonObject json, Object... path) {
JsonElement elem = asJson(json, path);
return elem == null ? null
: elem.getAsByte();
}
代码示例来源:origin: asakusafw/asakusafw
@Override
public void byteProperty(PropertyName name, JsonObject context) throws IOException {
JsonElement prop = property(context, name);
if (prop == null) {
return;
}
builder.add(name, prop.getAsByte());
}
代码示例来源:origin: NordicSemiconductor/Android-nRF-Mesh-Library
final int ttl = publish.get("ttl").getAsByte();
代码示例来源:origin: eatnumber1/google-gson
public Byte deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
try {
return json.getAsByte();
} catch (NumberFormatException e) {
throw new JsonSyntaxException(e);
} catch (UnsupportedOperationException e) {
throw new JsonSyntaxException(e);
} catch (IllegalStateException e) {
throw new JsonSyntaxException(e);
}
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-core
return (T) (Character) input.getAsCharacter();
} else if (expected == byte.class || expected == Byte.class) {
return (T) (Byte) input.getAsByte();
} else if (expected == short.class || expected == Short.class) {
return (T) (Short) input.getAsShort();
代码示例来源:origin: io.searchbox/jest-common
return (T) (Byte) id.getAsByte();
内容来源于网络,如有侵权,请联系作者删除!