use of javax.json.JsonString in project opentheso by miledrousset.
the class HandleClient method getIdHandle.
private String getIdHandle(String jsonText) {
if (jsonText == null)
return null;
// {"responseCode":1,"handle":"20.500.11942/opentheso443"}
JsonReader reader = Json.createReader(new StringReader(jsonText));
JsonObject jsonObject = reader.readObject();
reader.close();
JsonString values = jsonObject.getJsonString("handle");
if (values != null)
return values.getString();
return null;
}
use of javax.json.JsonString in project opentheso by miledrousset.
the class ArkClientRest method setIdArkHandle.
private boolean setIdArkHandle() {
if (jsonArk == null)
return false;
JsonReader reader = Json.createReader(new StringReader(jsonArk));
JsonObject jsonObject = reader.readObject();
reader.close();
JsonString values = jsonObject.getJsonString("Ark");
if (values == null)
idArk = null;
else
idArk = values.getString().trim();
values = jsonObject.getJsonString("Handle");
if (values == null)
idHandle = null;
else
idHandle = values.getString().trim();
loginJson.put("token", jsonObject.getJsonString("token"));
return true;
}
use of javax.json.JsonString in project jersey by jersey.
the class DocumentFilteringResource method filter.
@POST
public JsonArray filter(final JsonArray properties) {
final JsonArrayBuilder documents = Json.createArrayBuilder();
final List<JsonString> propertyList = properties.getValuesAs(JsonString.class);
for (final JsonObject jsonObject : DocumentStorage.getAll()) {
final JsonObjectBuilder documentBuilder = Json.createObjectBuilder();
for (final JsonString property : propertyList) {
final String key = property.getString();
if (jsonObject.containsKey(key)) {
documentBuilder.add(key, jsonObject.get(key));
}
}
final JsonObject document = documentBuilder.build();
if (!document.isEmpty()) {
documents.add(document);
}
}
return documents.build();
}
use of javax.json.JsonString in project torodb by torodb.
the class TableRefConverter method fromJsonArray.
public static TableRef fromJsonArray(TableRefFactory tableRefFactory, JsonArray tableRefJsonArray) {
TableRef tableRef = tableRefFactory.createRoot();
for (JsonValue tableRefNameValue : tableRefJsonArray) {
String tableRefName = ((JsonString) tableRefNameValue).getString();
tableRef = createChild(tableRefFactory, tableRef, tableRefName);
}
return tableRef;
}
use of javax.json.JsonString in project azure-iot-sdk-java by Azure.
the class ToolsTest method getValueFromJsonObject_input_key_empty.
// Tests_SRS_SERVICE_SDK_JAVA_TOOLS_12_010: [The function shall return empty string if any of the input is null]
@Test
public void getValueFromJsonObject_input_key_empty() {
// Arrange
String jsonString = "{\"deviceId\":\"xxx-device\",\"generationId\":\"111111111111111111\",\"etag\":\"MA==\",\"connectionState\":\"Disconnected\",\"status\":\"disabled\",\"statusReason\":null,\"connectionStateUpdatedTime\":\"0001-01-01T00:00:00\",\"statusUpdatedTime\":\"0001-01-01T00:00:00\",\"lastActivityTime\":\"0001-01-01T00:00:00\",\"cloudToDeviceMessageCount\":0,\"authentication\":{\"symmetricKey\":{\"primaryKey\":\"AAABBBCCC111222333444000\",\"secondaryKey\":\"111222333444555AAABBBCCC\"}}}";
StringReader stringReader = new StringReader(jsonString);
JsonReader jsonReader = Json.createReader(stringReader);
JsonObject jsonObject = jsonReader.readObject();
String key = "";
String expResult = "";
// Act
String result = Tools.getValueFromJsonObject(jsonObject, key);
// Assert
assertEquals(expResult, result);
}
Aggregations