apoc.load.jsonArray

Loading from local files requires setting apoc.import.file.enabled=true in apoc.conf. This is not supported on Aura. Aura instances are therefore limited to loading publicly hosted files.

Details

Syntax

apoc.load.jsonArray(url [, path, config ]) :: (value)

Description

Loads array from a JSON URL (e.g. web-API) to then import the given JSON file as a stream of values.

Input arguments

Name

Type

Description

url

STRING

The path to the JSON file.

path

STRING

A JSON path expression used to extract a certain part from the list. The default is: ``.

config

MAP

{ failOnError = true :: BOOLEAN, pathOptions :: LIST<STRING>, compression = "NONE" :: ["NONE", "BYTES", "GZIP", "BZIP2"", "DEFLATE", "BLOCK_LZ4", "FRAMED_SNAPPY"] }. The default is: {}.

Return arguments

Name

Type

Description

value

ANY

Data loaded from the given file.

Usage Examples

map.json contains a JSON document representing a person and their children.

map.json
{
  "foo":[1,2,3]
}

We’ll place this file into the import directory of our Neo4j instance. Let’s now write a query using the apoc.load.jsonArray procedure to explore this file.

The following query processes map.json and returns the content as Cypher data structures

CALL apoc.load.jsonArray("file:///map.json", "$.foo");
Results
value

[1, 2, 3]

Moreover, we can customize the Json path options, adding the config {pathOptions: LIST OF STRINGS}, where the strings are based on Enum<Option>. The default value is ["SUPPRESS_EXCEPTIONS", "DEFAULT_PATH_LEAF_TO_NULL"]. Note that we can also insert [], that is "without options". So with the following json:

{ "columns": {
      "col2": {
        "_id": "772col2"
      }
    }
}

we can execute (with default pathOptions):

CALL apoc.load.jsonArray($url, '$..columns');
Results
value

[ {"col2": { "_id": "772col2" }}, null, null ]

or, with custom path options:

CALL apoc.load.jsonArray($url, '$..columns', ['ALWAYS_RETURN_LIST']);
Results
value

[ {"col2": { "_id": "772col2" }} ]