Skip to content

Instantly share code, notes, and snippets.

@d108
Last active June 8, 2019 23:20
Show Gist options
  • Save d108/4f2b517308d504c85c085ceb14b63eea to your computer and use it in GitHub Desktop.
Save d108/4f2b517308d504c85c085ceb14b63eea to your computer and use it in GitHub Desktop.
val data1 = Klaxon().parse<String>(File(pathname).toString())
// This just tried to parse the filename.
val data2 = Klaxon().parse<File>(StringReader(File(pathname).toString())
// What's a Reader? I think that's what I need.
val data3 = Klaxon().parse<String>(File(pathname).readText())
// Oh, there's a readText(). Why didn't this work? It seems it's the wrong parse call evenough the types match.
val data4 = Klaxon().parseJsonObject(StringReader(File(pathname).readText()))
// There we go. I get two keys as a result.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment