apoc.convert.fromYaml
Function Apoc Extended
apoc.convert.fromYaml(value, $config) - Deserializes the YAML string to Neo4j value
Config parameters
The procedure support the following config parameters:
name | type | default | description |
---|---|---|---|
disable |
list of strings |
empty list |
To disable one or more configurations, enabled by default, of the library used under the hood. See here. |
enable |
list of strings |
empty list |
To enable one or more configurations of the library used under the hood. See here. |
mapping |
map of strings |
empty map |
to map complex YAMLs. In order to read complex types not supported by FasterXML Jackson, like Long…
we can use the mapping config to convert to the desired data type.
For example, if we have a YAML |
Usage Examples
We can convert any YAML string to list/map of nodes/rels
RETURN apoc.convert.fromYaml("a: 42
b: foo") AS value
value |
---|
|
RETURN apoc.convert.fromYaml("a: 42
b: foo", {mapping: {a: "Long"} }) AS value
value |
---|
|
RETURN apoc.convert.fromYaml("a: 42
b: foo", {enable: ['MINIMIZE_QUOTES'], disable: ['WRITE_DOC_START_MARKER']}) AS value
value |
---|
|
RETURN apoc.convert.fromYaml("---
- 1
- 2
- 3") as value
value |
---|
|
RETURN apoc.convert.fromYaml("---
- 1
- 2
- 3",
{mapping: {_: "Long"}}) as value
value |
---|
|
RETURN apoc.convert.fromYaml("---
a: 42
b: \"foo\"
c:
- 1
- 2
- 3") as value
value |
---|
|
RETURN apoc.convert.fromYaml("---
id: \"<elementID>\"
type: \"node\"
labels:
- \"Test\"
properties:
foo: 7") as value
value |
---|
|
RETURN apoc.convert.fromYaml("---
a: null
b: \"myString\"
c:
- 1
- \"2\"
- null") as value
value |
---|
|
RETURN apoc.convert.fromYaml("---
one:
id: \"8d3a6b87-39ad-4482-9ce7-5684fe79fc57\"
type: \"node\"
labels:
- \"Test\"
properties:
foo: 7
two:
id: \"3fc16aeb-629f-4181-97d2-a25b22b28b75\"
type: \"node\"
labels:
- \"Test\"
properties:
bar: 9
") as value
value |
---|
|
RETURN apoc.convert.fromYaml("---
id: \"94996be1-7200-48c2-81e8-479f28bba84d\"
type: \"relationship\"
label: \"KNOWS\"
start:
id: \"8d3a6b87-39ad-4482-9ce7-5684fe79fc57\"
type: \"node\"
labels:
- \"User\"
properties:
name: \"Adam\"
end:
id: \"3fc16aeb-629f-4181-97d2-a25b22b28b75\"
type: \"node\"
labels:
- \"User\"
properties:
name: \"Jim\"
age: 42
properties:
bffSince: \"P5M1DT12H\"
since: 1993.1
") as value
value |
---|
|