Skip to content

Commit

Permalink
Fix habr api changes in articles list json parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Garneg committed Dec 6, 2023
1 parent 207e4b7 commit 06a9e2a
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ class ArticlesListController {
var responseJson = Json.parseToJsonElement(response!!.body!!.string())
var articles = kotlin.run {
var articlesIds =
HabrDataParser.parseJson<List<Int>>(
(responseJson.jsonObject["articleIds"]
?: responseJson.jsonObject["newsIds"])!!.jsonArray
)
HabrDataParser.parseJson<List<Int>>((responseJson.jsonObject["publicationIds"] ?: responseJson.jsonObject["articleIds"])!!.jsonArray)
var pagesCount = responseJson.jsonObject["pagesCount"]?.jsonPrimitive?.intOrNull


Expand All @@ -45,9 +42,7 @@ class ArticlesListController {
try {
articlesRefs += mapOf(
it.toString() to HabrDataParser.parseJson(
responseJson.run {
jsonObject["articleRefs"] ?: jsonObject["newsRefs"]
}!!.jsonObject?.get(it.toString())!!
(responseJson.jsonObject["publicationRefs"] ?: responseJson.jsonObject["articleRefs"])!!.jsonObject.get(it.toString())!!
)
)
articleIdsfinal.add(it)
Expand Down

0 comments on commit 06a9e2a

Please sign in to comment.