Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorect parsing behaviour for array of strings #2375

Open
belovrv opened this issue Jul 21, 2023 · 1 comment
Open

Incorect parsing behaviour for array of strings #2375

belovrv opened this issue Jul 21, 2023 · 1 comment
Labels

Comments

@belovrv
Copy link

belovrv commented Jul 21, 2023

Describe the bug
Absence of " is ignored on Default json

To Reproduce
Json.Default.parseToJsonElement("[asdf, dsaf, dsaf]").jsonArray.size

Expected behavior
Exception

Environment

  • Kotlin version: 1.9.0
  • Library version: 1.5.1
  • Kotlin platforms: JVM
@belovrv belovrv changed the title Incorect Incorect parsing behaviour for array of strings Jul 21, 2023
@sandwwraith
Copy link
Member

This is a kind of deliberate design decision because we do not want to add a number parsing/validation strategy during JsonPrimitive parsing (see reasoning here: #1298 (comment)). E.g. "[3.0, 3e25, 3]" is a valid Json. asdf of course is not a valid number, but to determine that, we need to embed some kind of strategy anyway. On a contrary, we do not want to add a strategy but rather ask user to provide it explicitly with conversions like JsonPrimitive.int, JsonPrimitive.boolean, etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants