List of usage examples for com.google.gson JsonElement getAsJsonPrimitive
public JsonPrimitive getAsJsonPrimitive()
From source file:io.thinger.thinger.ResourceControlActivity.java
License:Open Source License
private void setInput(JsonElement input) { if (input.isJsonPrimitive()) { if (input.getAsJsonPrimitive().isBoolean()) { setInput(input.getAsJsonPrimitive().getAsBoolean()); }//from w w w . j a v a2 s . co m } }
From source file:io.thinger.thinger.ResourceControlActivity.java
License:Open Source License
private void setOutput(JsonElement output) { if (output != null) { if (output.isJsonPrimitive()) { if (output.getAsJsonPrimitive().isBoolean()) { setOutput(output.getAsJsonPrimitive().getAsBoolean()); } else if (output.getAsJsonPrimitive().isNumber()) { setOutput(output.getAsJsonPrimitive().getAsNumber()); } else if (output.getAsJsonPrimitive().isString()) { setOutput(output.getAsJsonPrimitive().getAsString()); }/*from ww w . j a va2s .co m*/ } } }
From source file:io.thinger.thinger.views.BoolValue.java
License:Open Source License
@Override public void refreshContent(JsonElement element) { if (element.isJsonPrimitive() && element.getAsJsonPrimitive().isBoolean()) { button.setChecked(element.getAsBoolean()); }/*from w w w. ja v a2 s . c o m*/ }
From source file:io.thinger.thinger.views.DeviceResource.java
License:Open Source License
public DeviceResource(String resourceName, JsonElement resourceDescription) { this.resourceName = resourceName; resourceType = ResourceType.NONE;/* ww w .j ava 2s. c o m*/ if (resourceDescription.isJsonObject()) { JsonObject object = resourceDescription.getAsJsonObject(); if (object.has("fn")) { JsonElement function = object.get("fn"); if (function.isJsonPrimitive()) { JsonPrimitive value = function.getAsJsonPrimitive(); if (value.isNumber()) { resourceType = ResourceType.get(value.getAsInt()); } } } } }
From source file:io.thinger.thinger.views.Element.java
License:Open Source License
public static Element createElement(LinearLayout layout, JsonElement element, boolean output) { if (element.isJsonPrimitive()) { return createPrimitiveElement("", element.getAsJsonPrimitive(), layout, output); } else if (element.isJsonObject()) { return new ObjectValue(layout, element.getAsJsonObject(), output); }//from w ww . j av a 2 s . c o m return null; }
From source file:io.thinger.thinger.views.NumberValue.java
License:Open Source License
@Override public void refreshContent(JsonElement element) { if (element.isJsonPrimitive() && element.getAsJsonPrimitive().isNumber()) { editText.setText(element.getAsNumber().toString()); }/* w w w. j a v a 2s . c o m*/ }
From source file:io.thinger.thinger.views.StringValue.java
License:Open Source License
@Override public void refreshContent(JsonElement element) { if (element.isJsonPrimitive() && element.getAsJsonPrimitive().isString()) { editText.setText(element.getAsString()); } else {// w w w .j a v a2 s. c om editText.setText(""); } }
From source file:it.smartcommunitylab.JSON.java
License:Apache License
public JSON() { gson = createGson().registerTypeAdapter(Date.class, dateTypeAdapter) .registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter) .registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter) .registerTypeAdapter(LocalDate.class, localDateTypeAdapter) .registerTypeAdapter(byte[].class, byteArrayAdapter) .registerTypeAdapter(Date.class, new JsonDeserializer<Date>() { public Date deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context) throws JsonParseException { return new Date(jsonElement.getAsJsonPrimitive().getAsLong()); }/*w w w.ja va 2 s. c o m*/ }).create(); }
From source file:jcoderwall.gson.DateTimeDeserializer.java
License:Open Source License
/** * {@inheritDoc}//from w w w . j a v a 2 s.c om */ @Override public DateTime deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { return new DateTime(json.getAsJsonPrimitive().getAsString()); }
From source file:jp.pay.model.EventDataDeserializer.java
License:Open Source License
private Object deserializeJsonElement(JsonElement element) { if (element.isJsonNull()) { return null; } else if (element.isJsonObject()) { Map<String, Object> valueMap = new HashMap<String, Object>(); populateMapFromJSONObject(valueMap, element.getAsJsonObject()); return valueMap; } else if (element.isJsonPrimitive()) { return deserializeJsonPrimitive(element.getAsJsonPrimitive()); } else if (element.isJsonArray()) { return deserializeJsonArray(element.getAsJsonArray()); } else {/*w w w. ja v a 2 s.c o m*/ System.err.println("Unknown JSON element type for element " + element + ". " + "If you're seeing this messaage, it's probably a bug in the Payjp Java " + "library. Please contact us by email at support@pay.jp."); return null; } }