Java Code Examples for com.google.gson.JsonObject#keySet()

The following examples show how to use com.google.gson.JsonObject#keySet() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResourceProcess.java    From GotoBrowser with GNU General Public License v3.0 6 votes vote down vote up
private void setSubtitle(String id, String code, String size) {
    if (activity.isCaptionAvailable()) {
        shipVoiceHandler.removeCallbacksAndMessages(null);
        JsonObject subtitle = KcSubtitleUtils.getQuoteString(id, code, size);
        Log.e("GOTO", subtitle.toString());
        for (String key : subtitle.keySet()) {
            String start_time = key.split(",")[0];
            if (Pattern.matches("[0-9]+", start_time)) {
                String text = subtitle.get(key).getAsString();
                int delay = Integer.parseInt(start_time);
                SubtitleRunnable sr = new SubtitleRunnable(text);
                shipVoiceHandler.postDelayed(sr, delay);
            }
        }
    }
}
 
Example 2
Source File: ContainerDetails.java    From docker-maven-plugin with Apache License 2.0 6 votes vote down vote up
private Map<String, String> extractNetworks(JsonObject networkSettings) {
    JsonObject networks = networkSettings.getAsJsonObject(NETWORKS);
    Set<String> keys = networks.keySet();
    if (keys == null || keys.isEmpty()) {
        return null;
    }
    Map<String, String> results = new HashMap<>();
    for (String key : keys) {
        JsonObject net = networks.getAsJsonObject(key);
        if (net.has(IP) && !net.get(IP).isJsonNull()) {
            results.put(key, net.get(IP).getAsString());
        }
    }

    return results;
}
 
Example 3
Source File: VectorColumnFiller.java    From secor with Apache License 2.0 6 votes vote down vote up
public void convert(JsonElement value, ColumnVector vect, int row) {
    if (value == null || value.isJsonNull()) {
        vect.noNulls = false;
        vect.isNull[row] = true;
    } else {
        MapColumnVector vector = (MapColumnVector) vect;
        JsonObject obj = value.getAsJsonObject();
        vector.lengths[row] = obj.size();
        vector.offsets[row] = row > 0 ? vector.offsets[row - 1] + vector.lengths[row - 1] : 0;

        // Ensure enough space is available to store the keys and the values
        vector.keys.ensureSize((int) vector.offsets[row] + obj.size(), true);
        vector.values.ensureSize((int) vector.offsets[row] + obj.size(), true);

        int i = 0;
        for (String key : obj.keySet()) {
            childConverters[0].convert(new JsonPrimitive(key), vector.keys, (int) vector.offsets[row] + i);
            childConverters[1].convert(obj.get(key), vector.values, (int) vector.offsets[row] + i);
            i++;
        }
    }
}
 
Example 4
Source File: ContainerDetails.java    From jkube with Eclipse Public License 2.0 6 votes vote down vote up
private Map<String, String> extractNetworks(JsonObject networkSettings) {
    JsonObject networks = networkSettings.getAsJsonObject(NETWORKS);
    Set<String> keys = networks.keySet();
    if (keys == null || keys.isEmpty()) {
        return null;
    }
    Map<String, String> results = new HashMap<>();
    for (String key : keys) {
        JsonObject net = networks.getAsJsonObject(key);
        if (net.has(IP) && !net.get(IP).isJsonNull()) {
            results.put(key, net.get(IP).getAsString());
        }
    }

    return results;
}
 
Example 5
Source File: DockerAccessWithHcClient.java    From docker-maven-plugin with Apache License 2.0 5 votes vote down vote up
private void logRemoveResponse(JsonArray logElements) {
    for (int i = 0; i < logElements.size(); i++) {
        JsonObject entry = logElements.get(i).getAsJsonObject();
        for (Object key : entry.keySet()) {
            log.debug("%s: %s", key, entry.get(key.toString()));
        }
    }
}
 
Example 6
Source File: KcaUtils.java    From kcanotify with GNU General Public License v3.0 5 votes vote down vote up
public static void sendUserAnalytics(Context context, String event, JsonObject value) {
    Bundle params = new Bundle();
    FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(context);
    if (value != null) {
        for (String key: value.keySet()) {
            params.putString(key, value.get(key).getAsString());
        }
    }
    mFirebaseAnalytics.logEvent(event, params);
}
 
Example 7
Source File: GsonUtil.java    From alpaca-java with MIT License 5 votes vote down vote up
/**
 * Checks if all Gson {@link SerializedName} annotation values (including inherited ones) in the JSON POJO are
 * present in the <strong>immediate</strong> JSON object.
 *
 * @param jsonPOJOClass the json pojo class
 * @param jsonObject    the json object
 *
 * @return the boolean
 */
public static boolean doesGsonPOJOMatch(Class jsonPOJOClass, JsonObject jsonObject) {
    ArrayList<SerializedName> gsonSerializedNameAnnotations = getGsonSerializedNameAnnotations(jsonPOJOClass);
    Set<String> jsonObjectKeys = jsonObject.keySet();

    List<String> classKeys = new ArrayList<>();
    gsonSerializedNameAnnotations.forEach((c) -> classKeys.add(c.value()));

    for (String key : jsonObjectKeys) {
        if (!classKeys.contains(key)) {
            return false;
        }
    }
    return true;
}
 
Example 8
Source File: LegacyBlockData.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
public void applyDefaultRemaps() {
	clear();

	JsonObject rootObject = ResourceUtils.getAsJson(MappingsData.getResourcePath("legacyblockdata.json"));
	for (String versionString : rootObject.keySet()) {
		JsonObject entriesObject = rootObject.get(versionString).getAsJsonObject();
		ArrayBasedIdRemappingTable table = getTable(ProtocolVersion.valueOf(versionString));
		for (String blockdataidString : entriesObject.keySet()) {
			table.setRemap(Integer.parseInt(blockdataidString), JsonUtils.getInt(entriesObject, blockdataidString));
		}
	}
}
 
Example 9
Source File: LegacyItemType.java    From ProtocolSupport with GNU Affero General Public License v3.0 5 votes vote down vote up
public void applyDefaultRemaps() {
	JsonObject rootObject = ResourceUtils.getAsJson(MappingsData.getResourcePath("legacyitemtype.json"));
	for (String versionString : rootObject.keySet()) {
		JsonObject entriesObject = rootObject.get(versionString).getAsJsonObject();
		ArrayBasedIdRemappingTable table = getTable(ProtocolVersion.valueOf(versionString));
		for (String itemidString : entriesObject.keySet()) {
			table.setRemap(Integer.parseInt(itemidString), JsonUtils.getInt(entriesObject, itemidString));
		}
	}
}
 
Example 10
Source File: QuerySerializer.java    From quaerite with Apache License 2.0 5 votes vote down vote up
private Query buildBoolean(JsonObject obj) {
    BooleanQuery bq = new BooleanQuery();
    for (BooleanClause.OCCUR occur : BooleanClause.OCCUR.values()) {
        JsonArray qArr = obj.getAsJsonArray(occur.toString().toLowerCase(Locale.US));
        if (qArr != null) {
            for (JsonElement el : qArr) {
                JsonObject clause = (JsonObject) el.getAsJsonObject();
                Set<String> keys = clause.keySet();
                if (keys.size() != 1) {
                    throw new IllegalArgumentException(
                            "boolean clause must have a single entry -- " +
                                    "the query: " + keys);
                }
                String queryType = JsonUtil.getSingleChildName(clause);
                JsonObject queryObject = clause.getAsJsonObject(queryType);

                if (queryObject == null) {
                    throw new IllegalArgumentException(
                            "boolean clause must contain a query");
                }
                Query child = buildQuery(queryType, queryObject);
                if (!(child instanceof SingleStringQuery)) {
                    throw new IllegalArgumentException(
                            "For now, boolean clauses may only contain SingleStringQueries");
                }
                bq.addClause(new BooleanClause(occur, (SingleStringQuery) child));
            }
        }
    }
    return bq;
}
 
Example 11
Source File: GsonRuntime.java    From jmespath-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Collection<JsonElement> getPropertyNames(JsonElement value) {
  if (value.isJsonObject()) {
    JsonObject object = (JsonObject) value;
    List<JsonElement> names = new ArrayList<>((object.size()));
    for (String s : object.keySet()) {
      names.add(createString(s));
    }
    return names;
  } else {
    return Collections.emptyList();
  }
}
 
Example 12
Source File: FeatureFactorySerializer.java    From quaerite with Apache License 2.0 5 votes vote down vote up
@Override
public FeatureFactories deserialize(JsonElement jsonElement, Type type,
                                    JsonDeserializationContext
                                            jsonDeserializationContext)
        throws JsonParseException {
    JsonObject jsonObject = jsonElement.getAsJsonObject();
    Map<String, FeatureFactory> featureSetMap = new HashMap<>();
    for (String name : jsonObject.keySet()) {
        featureSetMap.put(name, buildFeatureFactory(name, jsonObject.get(name)));
    }
    return new FeatureFactories(featureSetMap);
}
 
Example 13
Source File: JsonValueExtractor.java    From json-logic-java with MIT License 5 votes vote down vote up
public static Object extract(JsonElement element) {
  if (element.isJsonObject()) {
    Map<String, Object> map = new HashMap<>();
    JsonObject object = element.getAsJsonObject();

    for (String key : object.keySet()) {
      map.put(key, extract(object.get(key)));
    }

    return map;
  }
  else if (element.isJsonArray()) {
    List<Object> values = new ArrayList<>();

    for (JsonElement item : element.getAsJsonArray()) {
      values.add(extract(item));
    }

    return values;
  }
  else if (element.isJsonNull()) {
    return null;
  }
  else if (element.isJsonPrimitive()) {
    JsonPrimitive primitive = element.getAsJsonPrimitive();

    if (primitive.isBoolean()) {
      return primitive.getAsBoolean();
    }
    else if (primitive.isNumber()) {
      return primitive.getAsNumber().doubleValue();
    }
    else {
      return primitive.getAsString();
    }
  }

  return element.toString();
}
 
Example 14
Source File: JsonUtil.java    From java-trader with Apache License 2.0 5 votes vote down vote up
public static Object json2value(JsonElement json) {
    Object result = null;
    if ( json.isJsonNull() ) {
        result = null;
    }else if ( json.isJsonObject() ) {
        JsonObject json0 = (JsonObject)json;
        LinkedHashMap<String, Object> map = new LinkedHashMap<>();
        for(String key:json0.keySet()) {
            map.put(key, json2value(json0.get(key)));
        }
        result = map;
    }else if ( json.isJsonArray() ) {
        JsonArray arr = (JsonArray)json;
        ArrayList<Object> list = new ArrayList<>(arr.size());
        for(int i=0;i<arr.size();i++) {
            list.add(json2value(arr.get(i)));
        }
        result = list;
    } else if ( json.isJsonPrimitive() ) {
        JsonPrimitive p = (JsonPrimitive)json;
        if ( p.isBoolean() ) {
            result = p.getAsBoolean();
        }else if ( p.isNumber() ) {
            result = p.getAsDouble();
        }else if ( p.isString()) {
            result = p.getAsString();
        }else {
            result = p.getAsString();
        }
    }
    return result;
}
 
Example 15
Source File: Solr4Client.java    From quaerite with Apache License 2.0 5 votes vote down vote up
private List<StoredDocument> _getDocs(String requestUrl, Set<String> blackListFields) {
    List<StoredDocument> documents = new ArrayList<>();
    JsonResponse fullResponse = null;
    try {
        fullResponse = getJson(requestUrl);
    } catch (IOException | SearchClientException e) {
        LOG.warn("problem with " + url + " and " + requestUrl +
                " :: " + fullResponse.getMsg());
        return Collections.EMPTY_LIST;
    }

    JsonElement root = fullResponse.getJson();

    JsonObject response = (JsonObject) ((JsonObject) root).get("response");
    long totalHits = response.get("numFound").getAsLong();
    if (response.has("docs")) {
        JsonArray docs = (JsonArray) response.get("docs");
        for (JsonElement docElement : docs) {
            StoredDocument document = new StoredDocument();
            JsonObject docObj = (JsonObject) docElement;
            for (String key : docObj.keySet()) {
                if (!blackListFields.contains(key)) {
                    JsonElement value = docObj.get(key);
                    if (value.isJsonArray()) {
                        for (int j = 0; j < ((JsonArray) value).size(); j++) {
                            document.addNonBlankField(key,
                                    ((JsonArray) value).get(j).getAsString());
                        }
                    } else {
                        document.addNonBlankField(key, value.getAsString());
                    }
                }
            }
            LOG.trace("getting doc from solr: " +
                    document.getFields().get("id"));
            documents.add(document);
        }
    }
    return documents;
}
 
Example 16
Source File: CustomHttpClient.java    From openvidu with Apache License 2.0 5 votes vote down vote up
public JsonObject rest(HttpMethod method, String path, String body, int status, boolean exactReturnedFields,
		String jsonReturnedValue) throws Exception {
	JsonObject json = this.commonRest(method, path, body, status);
	JsonObject jsonObjExpected = null;
	jsonReturnedValue.replaceAll("'", "\"");
	try {
		jsonObjExpected = JsonParser.parseString(jsonReturnedValue).getAsJsonObject();
	} catch (JsonSyntaxException e1) {
		throw new Exception("Expected json element is a string without a JSON format: " + jsonReturnedValue);
	}

	if (exactReturnedFields) {
		if (jsonObjExpected.size() != json.size()) {
			throw new Exception(
					"Error in number of keys in JSON response to POST (" + json.toString() + ")" + path);
		}
	}
	for (String key : jsonObjExpected.keySet()) {
		Class<?> c1 = jsonObjExpected.get(key).getClass();
		Class<?> c2 = json.get(key).getClass();

		c1 = unifyNumberType(c1);
		c2 = unifyNumberType(c2);

		if (!c1.equals(c2)) {
			throw new Exception("Wrong class of property " + key);
		}
	}
	return json;
}
 
Example 17
Source File: AreaDataServiceImpl.java    From parker with MIT License 4 votes vote down vote up
@Override
public void save() {

    List<String> lines = FileUtils.read("d:/test/area-data.txt");
    String jsonStr = lines.get(0);
    JsonObject jsonObject = (JsonObject) new JsonParser().parse(jsonStr);

    // 省
    List<AreaData> provinceList = new ArrayList<>();

    JsonObject provinceJson = jsonObject.getAsJsonObject("86");
    Set<String> provinceCodeSet = provinceJson.keySet();

    provinceCodeSet.forEach(provinceCode -> {
        AreaData province = new AreaData();
        province.setId(provinceCode);
        province.setName(provinceJson.get(provinceCode).getAsString());
        province.setParent("86");
        provinceList.add(province);
        addList(province);

        // 市
        List<AreaData> cityList = new ArrayList<>();
        JsonObject cityJson = jsonObject.getAsJsonObject(provinceCode);
        Set<String> cityCodeSet = cityJson.keySet();
        for(String cityCode:cityCodeSet){
            AreaData city = new AreaData();
            city.setId(cityCode);
            city.setName(cityJson.get(cityCode).getAsString());
            city.setParent(provinceCode);
            cityList.add(city);
            addList(city);

            // 区县
            List<AreaData> countyList = new ArrayList<>();
            JsonObject countyJson = jsonObject.getAsJsonObject(cityCode);
            if(countyJson == null){
                continue;
            }
            Set<String> countyCodeSet = countyJson.keySet();
            if(countyCodeSet == null || countyCodeSet.size() == 0){
                continue;
            }
            for(String countyCode:countyCodeSet){
                AreaData county = new AreaData();
                county.setId(countyCode);
                System.out.println(countyCode);
                county.setName(countyJson.get(countyCode).getAsString());
                county.setParent(cityCode);
                countyList.add(county);
                addList(county);

                // 乡镇
                List<AreaData> townList = new ArrayList<>();
                JsonObject townJson = jsonObject.getAsJsonObject(countyCode);
                if(townJson == null){
                    continue;
                }
                Set<String> townCodeSet = townJson.keySet();
                if(townCodeSet == null || townCodeSet.size() == 0){
                    continue;
                }
                countyCodeSet.forEach(townCode -> {
                    AreaData town = new AreaData();
                    town.setId(townCode);
                    town.setName(townJson.get(townCode).getAsString());
                    town.setParent(countyCode);
                    countyList.add(town);
                    addList(town);
                });

            }
        }
    });

    // 清空this.areaDataList

    // 保存中国,最终形成一颗树
    AreaData country = new AreaData();
    country.setId("86");
    country.setName("中国");
    this.areaDataList.add(country);

    areaDataRepository.saveAll(this.areaDataList);
}
 
Example 18
Source File: LettuceJsonDumper.java    From sherlock with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void writeRawData(JsonObject json) throws IOException {
    Set<String> jsonKeys = json.keySet();
    Map<String, Map<String, String>> modelObjectKeys = new HashMap<>();
    Map<String, String[]> indexKeys = new HashMap<>();
    Map<String, List<ScoredValue<byte[]>>> anomalyTimestampKeys = new HashMap<>();
    Map<String, String> idKeys = new HashMap<>();
    Mapper<String> jobObjectMapper = new HashMapper();
    Mapper<String> emailObjectMapper = new HashMapper();
    Mapper<String> reportObjectMapper = new HashMapper();
    Mapper<String> druidClusterObjectMapper = new HashMapper();

    for (String key : jsonKeys) {
        if (json.get(key).isJsonObject()) {
            if (key.contains(DatabaseConstants.JOBS) && !key.contains(DatabaseConstants.DELETED_JOBS)) {
                modelObjectKeys.put(key, jobObjectMapper.map(instantiateJobs(json.getAsJsonObject(key))));
            } else if (key.contains(DatabaseConstants.REPORTS)) {
                modelObjectKeys.put(key, reportObjectMapper.map(gson.fromJson(json.getAsJsonObject(key), AnomalyReport.class)));
            } else if (key.contains(DatabaseConstants.EMAILS)) {
                modelObjectKeys.put(key, emailObjectMapper.map(gson.fromJson(json.getAsJsonObject(key), EmailMetaData.class)));
            } else if (key.contains(DatabaseConstants.DRUID_CLUSTERS)) {
                modelObjectKeys.put(key, druidClusterObjectMapper.map(gson.fromJson(json.getAsJsonObject(key), DruidCluster.class)));
            }
        } else if (json.get(key).isJsonArray()) {
            if (key.contains(DatabaseConstants.ANOMALY_TIMESTAMP)) {
                anomalyTimestampKeys.put(key, gson.fromJson(json.getAsJsonArray(key), new TypeToken<List<ScoredValue<byte[]>>>() { }.getType()));
            } else if (key.contains(DatabaseConstants.INDEX) && !key.contains(DatabaseConstants.DELETED)) {
                indexKeys.put(key, gson.fromJson(json.getAsJsonArray(key), String[].class));
            }
        } else if (key.equals(DatabaseConstants.CLUSTER_ID) || key.equals(DatabaseConstants.JOB_ID)) {
            idKeys.put(key, json.getAsJsonPrimitive(key).getAsString());
        } else {
            log.error("Key is not a Json object, Json array or Json primitive: key = {}", key);
        }
    }
    if (modelObjectKeys.size() > 0) {
        writeObjectsToRedis(modelObjectKeys);
    } else {
        log.info("Found zero objects in json dump!");
    }
    if (anomalyTimestampKeys.size() > 0) {
        writeAnomalyTimestampsToRedis(anomalyTimestampKeys);
    } else {
        log.info("Found zero anomaly timestamps in json dump!");
    }
    if (indexKeys.size() > 0) {
        writeIndexesToRedis(indexKeys);
    } else {
        log.info("Found zero index keys in json dump!");
    }
    if (idKeys.size() > 0) {
        writeIdsToRedis(idKeys);
    } else {
        log.info("Found zero Ids in json dump!");
    }
    log.info("Json dump is populated into redis.");
}
 
Example 19
Source File: SolrClient.java    From quaerite with Apache License 2.0 4 votes vote down vote up
@Override
public List<StoredDocument> getDocs(String idField, Set<String> ids,
                                    Set<String> whiteListFields,
                                    Set<String> blackListFields)
        throws IOException, SearchClientException {
    StringBuilder sb = new StringBuilder();
    int i = 0;
    sb.append(idField + ":(");
    for (String id : ids) {
        if (i++ > 0) {
            sb.append(" OR ");
        }
        sb.append("\"" + id + "\"");
    }

    sb.append(")");
    Map<String, String> qRequest = new HashMap<>();
    qRequest.put("query", sb.toString());
    qRequest.put("limit", Integer.toString(i + 10));
    if (whiteListFields.size() > 0) {
        String fields = StringUtils.join(whiteListFields, ",");
        qRequest.put("fields", fields);
    }
    String json = GSON.toJson(qRequest);
    JsonResponse fullResponse = postJson(url + "/select", json);
    if (fullResponse.getStatus() != 200) {
        LOG.warn("problem with " + url + " and " + json);
        return Collections.EMPTY_LIST;
    }
    List<StoredDocument> documents = new ArrayList<>();
    JsonElement root = fullResponse.getJson();
    JsonObject response = (JsonObject) ((JsonObject) root).get("response");
    long totalHits = response.get("numFound").getAsLong();
    if (response.has("docs")) {
        JsonArray docs = (JsonArray) response.get("docs");
        for (JsonElement docElement : docs) {
            StoredDocument document = new StoredDocument();
            JsonObject docObj = (JsonObject) docElement;
            for (String key : docObj.keySet()) {
                if (!blackListFields.contains(key)) {
                    JsonElement value = docObj.get(key);
                    if (value.isJsonArray()) {
                        for (int j = 0; j < ((JsonArray) value).size(); j++) {
                            document.addNonBlankField(key, ((JsonArray) value).get(j).getAsString());
                        }
                    } else {
                        document.addNonBlankField(key, value.getAsString());
                    }
                }
            }
            documents.add(document);
        }
    }
    return documents;
}
 
Example 20
Source File: IosSimulatorDeviceFinder.java    From MobileDeviceInfo with Apache License 2.0 4 votes vote down vote up
@Override
public Map<String, Object> readDeviceInfo(String localPath) throws IOException {
    Map<String, Object> parentMap;
    List<Map<String, Object>> deviceMapList = new ArrayList<>();
    Map<String, Object> device = new HashMap<>();

    Process simctlProcess = ProcessHelper.runTimeExec(String.format("%s%s", localPath, XCRUN_SIMCTL_SIMULATOR_INFORMATION_DEVICE_LIST_JSON));
    BufferedReader simctlReader = new BufferedReader(new InputStreamReader(simctlProcess.getInputStream()));

    StringBuilder deviceListStringBuilder = new StringBuilder();
    simctlReader.lines().map(String::trim).forEach(deviceListStringBuilder::append);

    Process xcdeviceProcess = ProcessHelper.runTimeExec(String.format("%s%s", localPath, XCRUN_XCDEVICE_SIMULATOR_INFORMATION_DEVICE_LIST_JSON));
    BufferedReader xcdeviceReader = new BufferedReader(new InputStreamReader(xcdeviceProcess.getInputStream()));

    StringBuilder deviceDetailInfoStringBuilder = new StringBuilder();
    xcdeviceReader.lines().map(String::trim).forEach(deviceDetailInfoStringBuilder::append);

    JsonObject devicesListJson = new Gson().fromJson(String.valueOf(deviceListStringBuilder), JsonObject.class).getAsJsonObject("devices");
    JsonArray devicesDetailInfoJson = new Gson().fromJson(String.valueOf(deviceDetailInfoStringBuilder), JsonArray.class);

    for (String currentDynamicKey : devicesListJson.keySet()) {
        JsonElement currentDynamicValue = devicesListJson.get(currentDynamicKey);
        for (JsonElement inCurrentValue : ((JsonArray) currentDynamicValue)) {
            parentMap = new HashMap<>();
            JsonObject currentKey = (JsonObject) inCurrentValue;
            if (currentKey.get("state").toString().contains("Booted")) {
                for (String setKey : currentKey.keySet()) {
                    parentMap.put(setKey,currentKey.get(setKey).toString().replaceAll("\"",""));
                }
                for (JsonElement currentElement : devicesDetailInfoJson) {
                    JsonObject currentElementValue = (JsonObject) currentElement;
                    if (currentElementValue.get("identifier").toString().contains(currentKey.get("udid").toString())) {
                        Map<String,String> operatingSystemVersion = new HashMap<>();
                        for (String key: currentElementValue.keySet()) {
                            if (key.contains("operatingSystemVersion")){
                                String[] strArray = currentElementValue.get(key).toString()
                                    .replaceAll("\\(","")
                                    .replaceAll("\\)","")
                                    .replaceAll("\"","")
                                    .split(" ");
                                operatingSystemVersion.put("productVersion",strArray[0]);
                                operatingSystemVersion.put("buildVersion",strArray[1]);
                                parentMap.putAll(operatingSystemVersion);
                            }
                            parentMap.put(key,currentElementValue.get(key).toString().replaceAll("\"",""));
                        }
                    }
                }
                deviceMapList.add(parentMap);
            }
        }
    }

    device.put("iosSimulator", deviceMapList);
    simctlReader.close();
    xcdeviceReader.close();
    return device;
}