pyjson

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package pyjson encodes JSON exactly as Python's json.dumps does with its defaults.

This matters wherever JSON is STORED rather than merely transmitted — the CRDT documents on disk and the frontmatter_json index column — because the Go and Python implementations have to produce identical bytes there. Two differences would otherwise creep in silently:

  • separators: Python defaults to ", " and ": "; Go's encoding/json emits "," and ":". A LIKE '%"pinned": true%' query written against one shape matches nothing against the other.
  • ensure_ascii: Python escapes every non-ASCII rune as \uXXXX (with surrogate pairs above the BMP); Go emits raw UTF-8. Any note with an emoji in its title stores different bytes.

Go additionally HTML-escapes <, > and & by default, which Python does not.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Object

func Object(pairs []Pair) string

Object encodes an object preserving the given key order.

func String

func String(s string) string

String encodes a Go string as a Python-compatible JSON string literal.

func Value

func Value(v any) string

Value encodes a value the way json.dumps would, with ", " / ": " separators. Map keys are sorted, matching Python dicts whose insertion order the caller does not control; ordered structures should use Object instead.

Types

type Pair

type Pair struct {
	Key   string
	Value any
}

Pair is one key/value entry, used where key ORDER is significant.

Jump to

Keyboard shortcuts

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