json

package
v1.2.3 Latest Latest
Warning

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

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

Documentation

Overview

Package json provides APOC JSON functions.

This package implements all apoc.json.* functions for working with JSON data in Cypher queries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compact

func Compact(jsonStr string) string

Compact removes whitespace from JSON.

Example:

apoc.json.compact('{\n  "name": "Alice"\n}') => '{"name":"Alice"}'

func Delete

func Delete(jsonStr, path string) string

Delete removes a value from JSON at a path.

Example:

apoc.json.delete('{"name":"Alice","age":30}', '$.age')
=> '{"name":"Alice"}'

func Filter

func Filter(jsonStr string, predicate func(interface{}) bool) string

Filter filters a JSON array based on a predicate.

Example:

apoc.json.filter('[1,2,3,4,5]', 'x > 3') => '[4,5]'

func Flatten

func Flatten(jsonStr string) string

Flatten flattens a nested JSON structure.

Example:

apoc.json.flatten('{"user":{"name":"Alice"}}')
=> '{"user.name":"Alice"}'

func Keys

func Keys(jsonStr string) []string

Keys returns all keys from a JSON object.

Example:

apoc.json.keys('{"name":"Alice","age":30}') => ['name', 'age']

func Map

func Map(jsonStr string, transform func(interface{}) interface{}) string

Map transforms a JSON array.

Example:

apoc.json.map('[1,2,3]', 'x * 2') => '[2,4,6]'

func Merge

func Merge(jsonStrs ...string) string

Merge merges multiple JSON objects.

Example:

apoc.json.merge('{"a":1}', '{"b":2}') => '{"a":1,"b":2}'

func Parse

func Parse(jsonStr string) interface{}

Parse parses a JSON string into a value.

Example:

apoc.json.parse('{"name":"Alice"}') => {name: 'Alice'}

func Path

func Path(jsonStr, path string) interface{}

Path extracts a value from JSON using a path expression.

Example:

apoc.json.path('{"user":{"name":"Alice"}}', '$.user.name') => 'Alice'

func Pretty

func Pretty(jsonStr string) string

Pretty formats JSON with indentation.

Example:

apoc.json.pretty('{"name":"Alice"}') => formatted JSON

func Reduce

func Reduce(jsonStr string, initial interface{}, reducer func(interface{}, interface{}) interface{}) interface{}

Reduce reduces a JSON array to a single value.

Example:

apoc.json.reduce('[1,2,3,4,5]', 0, 'acc + x') => 15

func Set

func Set(jsonStr, path string, value interface{}) string

Set sets a value in JSON at a path.

Example:

apoc.json.set('{"user":{}}', '$.user.name', 'Alice')
=> '{"user":{"name":"Alice"}}'

func Size

func Size(jsonStr string) int

Size returns the size of a JSON structure.

Example:

apoc.json.size('{"name":"Alice","age":30}') => 2
apoc.json.size('[1,2,3,4,5]') => 5

func Stringify

func Stringify(value interface{}) string

Stringify converts a value to JSON string.

Example:

apoc.json.stringify({name: 'Alice'}) => '{"name":"Alice"}'

func Type

func Type(jsonStr string) string

Type returns the type of a JSON value.

Example:

apoc.json.type('{"name":"Alice"}') => 'object'
apoc.json.type('[1,2,3]') => 'array'

func Unflatten

func Unflatten(jsonStr string) string

Unflatten unflattens a flat JSON structure.

Example:

apoc.json.unflatten('{"user.name":"Alice"}')
=> '{"user":{"name":"Alice"}}'

func Validate

func Validate(jsonStr string) bool

Validate validates a JSON string.

Example:

apoc.json.validate('{"name":"Alice"}') => true
apoc.json.validate('{invalid}') => false

func Values

func Values(jsonStr string) []interface{}

Values returns all values from a JSON object.

Example:

apoc.json.values('{"name":"Alice","age":30}') => ['Alice', 30]

Types

This section is empty.

Jump to

Keyboard shortcuts

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