json

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package json provides JSON reading and writing functionality for DataFrames.

Supports two orientations:

  • "records": [{"col": val, ...}, ...] (default)
  • "columns": {"col": [val, ...], ...}

Also supports JSONL format (one record per line).

Example:

// Read JSON
df, err := json.ReadJSON("data.json",
    json.Orient("records"),
)

// Write JSON
err = json.WriteJSON(df, "output.json",
    json.Orient("columns"),
)

// JSONL format
df, err := json.ReadJSON("data.jsonl", json.Lines())

Package json provides JSON reading and writing functionality for DataFrames.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadJSON

func ReadJSON(path string, opts ...JSONOption) (*dataframe.DataFrame, error)

ReadJSON reads a JSON file and returns a DataFrame.

func ToJSON

func ToJSON(df *dataframe.DataFrame, path string) error

ToJSON is a convenience method for writing a DataFrame to JSON.

func WriteJSON

func WriteJSON(df *dataframe.DataFrame, path string, opts ...JSONOption) error

WriteJSON writes a DataFrame to a JSON file.

Types

type JSONOption

type JSONOption func(*JSONReader) error

JSONOption is a functional option for configuring JSONReader.

func Lines

func Lines() JSONOption

Lines enables JSONL format (one record per line).

func Orient

func Orient(format string) JSONOption

Orient sets the JSON format orientation. "records": [{"col": val, ...}, ...] "columns": {"col": [val, ...], ...}

func WithIndent

func WithIndent() JSONOption

WithIndent enables pretty-printing.

type JSONReader

type JSONReader struct {
	// contains filtered or unexported fields
}

JSONReader reads JSON files into DataFrames.

type JSONWriter

type JSONWriter struct {
	// contains filtered or unexported fields
}

JSONWriter writes DataFrames to JSON files.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL