APOC: JSON / JSONL
GrafitoDB provides JSON loading and import procedures inspired by APOC.
apoc.load.json
Load a JSON object or array from a file or URL.
Signature
Arguments
source(string): file path,file://URL, or HTTP(S) URL.- You can also read from tar archives by using
path!member.json.
Return
- If the JSON is an object, returns a single row with
value= object. - If the JSON is an array, returns one row per element.
Example
apoc.load.jsonArray
Ensure the JSON payload is an array.
Signature
If the payload is not an array, the procedure raises an error.
apoc.load.jsonParams
Load JSON with query params, headers, and request options.
Signature
Arguments
source(string): file path or HTTP(S) URL.params(map): query parameters to append to the URL.headers(map): HTTP headers.options(map, optional):method(string, defaultGET)payload(string | bytes | map | list)timeout(number)retry(integer)failOnError(boolean, defaulttrue)headers(map) additional headersauth(string or{user, password}map)
Example
CALL apoc.load.jsonParams(
'https://api.example.com/users',
{limit: 10},
{Accept: 'application/json'},
{timeout: 5, retry: 2}
) YIELD value
RETURN value
Caching (HTTP GET only)
If GRAFITO_APOC_CACHE_DIR is set and the request is a simple GET (no payload,
headers, or auth), GrafitoDB caches the response body on disk and reuses it.
apoc.import.json
Import nodes and relationships from JSON or JSONL.
Signature
Arguments
source(string | bytes): file path, URL, or raw bytes.options(map, optional):compression:DEFLATE,GZIP,BZ2,XZ,ZIPpath: zip entry name (whencompression = "ZIP")idField(defaultid)labelsField(defaultlabels)propertiesField(defaultproperties)relTypeField(defaultlabel)startField(defaultstart)endField(defaultend)typeField(defaulttype)
Input Formats
GrafitoDB accepts:
1) JSON array of entries
2) JSON object with {nodes: [...], relationships: [...]}
3) JSONL (one JSON object per line)
Entries are treated as nodes unless one of the following is true:
typeFieldis set torelationship/rel/edgestartFieldorendFieldis present
Node entry example
Relationship entry example
Example import
Notes
- Relationship references must point to existing node IDs in the same import.
- Invalid JSON raises an error; JSONL is parsed line by line.