JetBrains / educational-plugin

Educational plugin to learn and teach programming languages such as Kotlin, Java, Python, JavaScript, and others right inside of JetBrains IntelliJ Platform based IDEs.
https://jetbrains.com/edu-products
Apache License 2.0
151 stars 51 forks source link

Read text directly from JSON #37

Closed fedefernandez closed 1 year ago

fedefernandez commented 1 year ago

Forget if there is a better place for these questions. We need to read the file text contents directly from the generated JSON, like, for example the following one:

    {
      "name" : "project/build.properties",
      "is_visible" : true,
      "text" : "G93YWnJ6W3b0cZLnzYN+cqn6W1VgW/kvdUwkTJkU4ic="
    }

Is there any way to do it properly? Is it encoded with some key? Looking through the source code I have seen that the plugin uses Base64.decodeBase64(encodedText) but the obtained ByteArray doesn't match with the expected text, which will be something like sbt.version = 1.6.2 in the text above.

import org.apache.commons.codec.binary.Base64
fun main() {
    val content = Base64.decodeBase64("G93YWnJ6W3b0cZLnzYN+cqn6W1VgW/kvdUwkTJkU4ic=")
    println(String(content)) // ��Zrz[v�q��̓~r��[U`[�/uL$L��'
}

Note: I have tried different charsets (UTF-8, UTF-16, US Ascii, ...) with no luck.

Thanks

fedefernandez commented 1 year ago

Since we don't need to read courses developed by other parties, we will add an intermediate step for generating a JSON with the plain text.