holgerbrandl / krangl

krangl is a {K}otlin DSL for data w{rangl}ing
MIT License
560 stars 50 forks source link

Not parsing embedded json arrays #151

Open iamsteveholmes opened 2 years ago

iamsteveholmes commented 2 years ago
Screen Shot 2022-06-24 at 10 59 56 AM

I was parsing a file but I simplified to a string for the example. When reading the file I got a somewhat different casting exception from JsonArray to JsonObject. Here is the full stacktrace from the screenshot:

class java.lang.String cannot be cast to class com.beust.klaxon.JsonObject (java.lang.String is in module java.base of loader 'bootstrap'; com.beust.klaxon.JsonObject is in unnamed module of loader java.net.URLClassLoader @64d1cb43)
java.lang.ClassCastException: class java.lang.String cannot be cast to class com.beust.klaxon.JsonObject (java.lang.String is in module java.base of loader 'bootstrap'; com.beust.klaxon.JsonObject is in unnamed module of loader java.net.URLClassLoader @64d1cb43)
    at krangl.JsonIOKt.fromJsonArray(JsonIO.kt:149)
    at krangl.JsonIOKt.fromJsonString(JsonIO.kt:50)
    at Line_231.<init>(Line_231.jupyter-kts:14)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.evalWithConfigAndOtherScriptsResults(BasicJvmScriptEvaluator.kt:100)
    at kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.invoke$suspendImpl(BasicJvmScriptEvaluator.kt:47)
    at kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.invoke(BasicJvmScriptEvaluator.kt)
    at kotlin.script.experimental.jvm.BasicJvmReplEvaluator.eval(BasicJvmReplEvaluator.kt:49)
    at org.jetbrains.kotlinx.jupyter.repl.impl.InternalEvaluatorImpl$eval$resultWithDiagnostics$1.invokeSuspend(InternalEvaluatorImpl.kt:103)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:279)
    at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:85)
    at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
    at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
    at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
    at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
    at org.jetbrains.kotlinx.jupyter.repl.impl.InternalEvaluatorImpl.eval(InternalEvaluatorImpl.kt:103)
    at org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl$execute$1$result$1.invoke(CellExecutorImpl.kt:70)
    at org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl$execute$1$result$1.invoke(CellExecutorImpl.kt:68)
    at org.jetbrains.kotlinx.jupyter.ReplForJupyterImpl.withHost(repl.kt:642)
    at org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl.execute(CellExecutorImpl.kt:68)
    at org.jetbrains.kotlinx.jupyter.repl.CellExecutor$DefaultImpls.execute$default(CellExecutor.kt:14)
    at org.jetbrains.kotlinx.jupyter.ReplForJupyterImpl$evalEx$1.invoke(repl.kt:451)
    at org.jetbrains.kotlinx.jupyter.ReplForJupyterImpl$evalEx$1.invoke(repl.kt:440)
    at org.jetbrains.kotlinx.jupyter.ReplForJupyterImpl.withEvalContext(repl.kt:404)
    at org.jetbrains.kotlinx.jupyter.ReplForJupyterImpl.evalEx(repl.kt:440)
    at org.jetbrains.kotlinx.jupyter.ReplForJupyterImpl.eval(repl.kt:492)
    at org.jetbrains.kotlinx.jupyter.messaging.ProtocolKt$shellMessagesHandler$res$1.invoke(protocol.kt:301)
    at org.jetbrains.kotlinx.jupyter.messaging.ProtocolKt$shellMessagesHandler$res$1.invoke(protocol.kt:300)
    at org.jetbrains.kotlinx.jupyter.JupyterConnection$runExecution$execThread$1.invoke(connection.kt:180)
    at org.jetbrains.kotlinx.jupyter.JupyterConnection$runExecution$execThread$1.invoke(connection.kt:178)
    at kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)
holgerbrandl commented 2 years ago

Could you post the example as text?