Skip to content

toJson() drops row objects when a real "value" column contains only nulls #2035

Description

@chimission

Description

DataFrame.toJson() incorrectly serializes a multi-column DataFrame as an array of null values when a column named value contains only nulls, even though other columns contain valid data.

Minimal reproduction

import org.jetbrains.kotlinx.dataframe.api.dataFrameOf
import org.jetbrains.kotlinx.dataframe.io.toJson

fun main() {
    val df =
        dataFrameOf(
            "value" to listOf<Double?>(null, null),
            "name" to listOf("Alice", "Bob"),
        )

    println(df.toJson())
}

Actual result

[null,null]

Expected result

[
  {
    "value": null,
    "name": "Alice"
  },
  {
    "value": null,
    "name": "Bob"
  }
]

Environment

  • Kotlin: 2.2.21
  • Kotlin DataFrame: 1.0.0-Beta5
  • JDK: 21
  • Gradle: 9.4.1
  • OS: Windows 11

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't workingfilesreading/writing from/to files

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions