如何读取和解析 gradle.kts 中的 .json 文件?

How to read and parse .json file in gradle.kts?

我的json是

{"enable": true}

放置在 android 工作室的资产文件夹下

所以我需要获取该值并在 build.gradle.kts

中使用它
gradle.buildFinished {
try {
    val file = File("app/src/main/assets/soundEnable.json")
    val json = groovy.json.JsonSlurper().parseText(file.readText()) as Map<String, String>
    if (json["enable"] as Boolean) {
        //do something
    }
} catch (ignore: Throwable) {
    println("=======")
    println(ignore.localizedMessage)
    println(ignore.cause)
    println(ignore.stackTrace)
    println("=======")
}

}