Skip to content

Added Json instance overload to readJson(inputStream, ...)#1869

Open
Jolanrensen wants to merge 4 commits into
masterfrom
jsonInstance-overload
Open

Added Json instance overload to readJson(inputStream, ...)#1869
Jolanrensen wants to merge 4 commits into
masterfrom
jsonInstance-overload

Conversation

@Jolanrensen
Copy link
Copy Markdown
Collaborator

Fixes #459

In the same vein as readCsv/readTsv/readDelim, the overload that takes an InputStream now gains an underlying-library-specific parameter to customize how it parses from the stream. This is an advanced use-case, but it can prevent users having to first manually parse their JSON manually before passing it onto DataFrame.
Since it's an advanced feature, only adding it to the InputStream overload makes sense. If we ever swap out the underlying library, only this function would break.

New example:

DataFrame.readJson(
    stream = myJson.byteInputStream(),
    jsonInstance = Json {
        isLenient = true
        allowTrailingComma = true
        allowComments = true
    },
)

@Jolanrensen Jolanrensen added enhancement New feature or request files reading/writing from/to files API If it touches our API labels May 20, 2026
@Jolanrensen Jolanrensen force-pushed the jsonInstance-overload branch from 38224db to 659b2c0 Compare May 20, 2026 18:16
@Jolanrensen Jolanrensen requested review from koperagen and zaleslaw May 21, 2026 11:23
keyValuePaths: List<JsonPath> = emptyList(),
typeClashTactic: TypeClashTactic = ARRAY_AND_VALUE_COLUMNS,
unifyNumbers: Boolean = true,
jsonInstance: Json = Json.Default,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, not sure i really like this name. configuration maybe? Maybe reference from other libraries (kotlinx.serialization probably only ever uses it as receiver?)

Copy link
Copy Markdown
Collaborator

@koperagen koperagen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

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

Labels

API If it touches our API enhancement New feature or request files reading/writing from/to files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Single Kotlinx.serialization options overload for DataFrame.readJson()

2 participants