JetBrains/educational-plugin

Read text directly from JSON

fedefernandez opened this issue · 1 comments

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

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.