json

package module
v0.0.0-...-b62ae7e Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package json provides a MetaLoader for JSON-formatted frontmatter.

Frontmatter is a JSON object at the start of the file, terminated by a closing }\n on its own line:

{
"title": "My Post",
"tags": ["go", "web"]
}
body content here

Index

Constants

This section is empty.

Variables

View Source
var Loader = func(raw []byte) (map[string]any, []byte, error) {
	head, body := split(raw)
	if head == nil {
		return map[string]any{}, body, nil
	}
	meta := map[string]any{}
	if err := stdjson.Unmarshal(head, &meta); err != nil {
		return nil, nil, err
	}
	return meta, body, nil
}

Loader parses JSON frontmatter and returns the metadata and body. Files with no {\n prefix are returned as body-only with empty metadata.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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