kotlinx.serialization icon indicating copy to clipboard operation
kotlinx.serialization copied to clipboard

Different behaviour of encodeToString and encodeToJsonElement on iOS simulator and physical iOS device or android simulator

Open KotlinWay opened this issue 2 years ago • 1 comments

Describe the bug This code:

data class Req(val id: Int)
val req = Req(id = 5000)
Json.encodeToString(req) 

on the physical device iOS and on the emulator android works correctly, but on the iOS emulator, the length of the literal is put in json instead of the field value.

{
    "id": 4
}

To Reproduce

data class Req(val id: Int)
val req = Req(id = 5000)
Json.encodeToString(req) 

Expected behavior Getting the correct json on the ios emulator

{
    "id": 5000
}

Environment

  • Kotlin version: 1.6.10
  • Library version: 1.3.1
  • Kotlin platforms: Native
  • Gradle version: 7.1.3
  • IDE version: XCode 13.1 / AS 2021.2.1 Patch 1
  • Other relevant context: simulator iPhone 11 iOS 15.0

KotlinWay avatar Jul 19 '22 07:07 KotlinWay

Hi, do you by any chance have an open-source reproducer?

qwwdfsad avatar Jul 19 '22 08:07 qwwdfsad

Please reopen if the issue is still actual.

sandwwraith avatar Feb 06 '23 17:02 sandwwraith