Closed NicolasRouquette closed 3 years ago
Can you make a minimal reproducer?
I tried this and it works with no problem:
case class RepoIssue(repo_id: Int, issue_number: Int) derives NativeConverter
@Test
def yolo: Unit =
val issues = Seq(
RepoIssue(1, 1),
RepoIssue(2, 2),
RepoIssue(3, 3)
)
val issuesJson = """ [{"repo_id":1,"issue_number":1},{"repo_id":2,"issue_number":2},{"repo_id":3,"issue_number":3}] """.trim
val nc = NativeConverter[Seq[RepoIssue]]
assertEquals(issues, nc.fromJson(issuesJson))
assertEquals(issuesJson, nc.toJson(issues))
I haven't used sttp before, but my guess would be that this line is the problem:
val backend = HttpURLConnectionBackend()
I don't think Scala.js would implement java.net.HttpURLConnection
.
Hey @NicolasRouquette going to close this, please reopen if you make a reproducer
I am trying to use this library to parse some data from the Zenhub API.
At runtime, I get an error:
I noticed that
NativeConverter.fromJson
is defined as:which means that we get the default value for the optional
reviver
argument ofJSON.parse
:Since the default value is
???
, the exception makes sense.What is a suitable function that we can provide here?
How is it that this problem has not happened before given that it has been several years since the scalajs JSON.parse method has required 2 arguments? -- see this change: https://github.com/scala-js/scala-js/commit/5fd2ff241040fb5d18b3a4a8176f481fa7462710