Skip to content

Commit

Permalink
fix(core-websdk/cloud_config): fix null value
Browse files Browse the repository at this point in the history
  • Loading branch information
xz-dev committed Aug 12, 2022
1 parent fd949d6 commit 8096e27
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ fun app1to2(oldJson: JSONObject): JSONObject? {
else -> s.lowercase()
}

if (oldJson.getInt("base_version") != 1) return null
if (oldJson.optInt("base_version") != 1) return null
val targetCheckerJson = oldJson.getJSONObject("app_config")
.getJSONObject("target_checker")
val map = mapOf(
"base_version" to 2,
"config_version" to oldJson.getJSONObject("info").getString("config_version"),
"uuid" to oldJson.getString("uuid"),
"config_version" to oldJson.getJSONObject("info").optInt("config_version"),
"uuid" to oldJson.optString("uuid"),
"base_hub_uuid" to oldJson.getJSONObject("app_config")
.getJSONObject("hub_info")
.getString("hub_uuid"),
.optString("hub_uuid"),
"info" to mapOf(
"name" to oldJson.getJSONObject("info").getString("app_name"),
"url" to oldJson.getJSONObject("info").getString("url"),
"name" to oldJson.getJSONObject("info").optString("app_name"),
"url" to oldJson.getJSONObject("info").optString("url"),
"extra_map" to mapOf(
apiConvert(targetCheckerJson.getString("api")) to targetCheckerJson.getString("extra_string")
apiConvert(targetCheckerJson.getString("api")) to targetCheckerJson.optString("extra_string")
)
),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ fun hub5to6(oldJson: JSONObject): JSONObject? {
"1c010cc9-cff8-4461-8993-a86cd190d377",
"6a6d590b-1809-41bf-8ce3-7e3f6c8da945",
)
if (oldJson.getInt("base_version") != 5) return null
val uuid = oldJson.getString("uuid")
if (oldJson.optInt("base_version") != 5) return null
val uuid = oldJson.optString("uuid")
val map = mapOf(
"base_version" to 6,
"config_version" to oldJson.getJSONObject("info").getString("config_version"),
"config_version" to oldJson.getJSONObject("info").optString("config_version"),
"uuid" to uuid,
"info" to mapOf(
"hub_name" to oldJson.getJSONObject("info").getString("hub_name"),
"hub_name" to oldJson.getJSONObject("info").optString("hub_name"),
"hub_icon_url" to "",
),
"target_check_api" to if (uuid in versionCodeHubs) "index" else "version_number",
"api_keywords" to oldJson.getJSONArray("api_keywords"),
"app_url_templates" to oldJson.getJSONArray("app_url_templates"),
"api_keywords" to oldJson.optJSONArray("api_keywords"),
"app_url_templates" to oldJson.optJSONArray("app_url_templates"),
)
return JSONObject(map)
}

0 comments on commit 8096e27

Please sign in to comment.