jsonedit

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2025 License: Apache-2.0 Imports: 18 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

JSON Edit

JSON Edit Logo

A web-based JSON editor application.

Features

  • Edit JSON files via a web interface
  • Compare JSON files
  • Read-only mode option
  • Configurable indentation

Show me

Home Page

The landing page of the application provides quick access to all main features. From here, you can:

  • Create a new JSON document
  • Open an existing JSON file
  • Access the comparison tool

Home Page

JSON Editor

A full-featured JSON editor with syntax highlighting and validation. This view allows you to:

  • Edit JSON content
  • Save changes to files

JSON Editor

JSON Viewer

A read-only view for JSON documents with collapsible sections. This view is ideal for:

  • Reviewing JSON data without risk of accidental changes

JSON Viewer

JSON Comparison

A comparison tool that highlights differences between two JSON documents. Features include:

  • Visual highlighting of added, modified, and removed elements

JSON Comparison

Debug Visualizer

An advanced debugging tool available in debug mode that shows:

  • HTTP request and response details
  • Application logs and events
  • Performance metrics
  • Request tracing information

Debug Visualizer

Call it at /__viz

Usage

# Run with default settings
jsonedit

# Run with custom settings
jsonedit --port 3000 --host 0.0.0.0 --indent "    " --read-only

Configuration

The application can be configured using command-line flags or environment variables:

Flag Environment Variable Default Description
--port JSON_EDIT_PORT 8080 Port to listen on
--host JSON_EDIT_HOST localhost Host to listen on
--indent JSON_EDIT_INDENT " " Indentation level
--read-only JSON_EDIT_READ_ONLY false Read-only mode
--log-level JSON_EDIT_LOG_LEVEL info Log level (debug, info, warn, error)

When running in debug mode (by setting --log-level debug), the application exposes a /__viz endpoint that provides visualization and logging of HTTP requests and responses, which is useful for debugging and development.

Building and Releasing

This project uses GoReleaser to build and release binaries for multiple platforms:

  • macOS (arm64, amd64)
  • Linux (arm64, amd64)
  • Windows (amd64)
Local Testing

To test the build process locally:

# Install GoReleaser if you haven't already
go install github.com/goreleaser/goreleaser@latest

# Test the build without releasing
goreleaser build --snapshot --clean

The built binaries will be available in the dist/ directory.

Creating a Release

To create a new release:

  1. Tag the commit you want to release:

    git tag -a v0.1.0 -m "First release"
    git push origin v0.1.0
    
  2. The GitHub Actions workflow will automatically build and release the binaries.

  3. The release will be available on the GitHub Releases page.

Used dependencies

Go dependencies

This project uses the following dependencies not from the same author:

Used Fonts

This project uses the following fonts:

  • Monaspace - Used for monospaced text
  • Jost - Used for non-monospaced text

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEmbeddedFileSystem added in v0.2.0

func GetEmbeddedFileSystem() http.FileSystem

GetEmbeddedFileSystem returns a http.FileSystem that serves files from the embedded filesystem

Types

type App

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

App represents the core application with configuration options such as host, port, JSON indentation, and logging.

func NewApp

func NewApp(opts ...AppOption) (*App, error)

NewApp initializes a new App instance with provided AppOption configurations and returns the configured App or an error.

func (*App) Run

func (app *App) Run() error

Run starts the HTTP server, register route handlers, and optionally enables debug mode with request/response logging.

type AppOption

type AppOption func(*App) error

AppOption represents a function that configures an App instance and may return an error during the setup process.

func WithDebug

func WithDebug(debug bool) AppOption

WithDebug sets the debug mode for the application, enabling detailed logging for requests and responses.

func WithHost

func WithHost(host string) AppOption

WithHost sets the hostname or IP address that the application server will use to listen for incoming HTTP requests.

func WithIndent

func WithIndent(indent string) AppOption

WithIndent sets the string used for JSON output indentation in the application configuration.

func WithLogger

func WithLogger(logger *slog.Logger) AppOption

WithLogger sets the application's logger for structured logging and returns an AppOption for configuration.

func WithNoBrowser added in v0.5.0

func WithNoBrowser(noBrowser bool) AppOption

WithNoBrowser sets the noBrowser field in the App to determine if the app should refrain from opening a browser on startup.

func WithPort

func WithPort(port int) AppOption

WithPort sets the TCP port for the application server to listen on and returns an AppOption for configuration.

func WithReadOnly

func WithReadOnly(readOnly bool) AppOption

WithReadOnly sets the application's read-only mode to the specified value.

type EditPageData

type EditPageData struct {

	// Content represents the primary JSON content to be displayed or edited on the page.
	Content string

	// Error represents an optional error message to be displayed on the page.
	Error string

	// FormContent contains HTML content used to render an editable JSON form or dynamic interface for the edit page.
	FormContent template.HTML

	// ReadOnly indicates whether the content or form should be displayed in a non-editable mode.
	ReadOnly bool
}

Define data structures for templates

Directories

Path Synopsis
cmd
jsonedit command

Jump to

Keyboard shortcuts

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