apoc.convert.toYaml
Function Apoc Extended
apoc.convert.toYaml(value, $config) - Serializes the given value to a YAML string
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. |
Usage Examples
We can convert any value, including list/map of nodes/rels/paths
Convert map to YAML
RETURN apoc.convert.toYaml({a:42,b:"foo"}) AS value
value |
---|
|
Convert map to YAML, with custom feature
RETURN apoc.convert.toYaml({a:42,b:"foo"},
{enable: ['MINIMIZE_QUOTES'], disable: ['WRITE_DOC_START_MARKER']}
) AS value
value |
---|
|
Convert node to YAML
RETURN apoc.convert.toYaml({a:42,b:"foo"},
{enable: ['MINIMIZE_QUOTES'], disable: ['WRITE_DOC_START_MARKER']}
) AS value
value |
---|
|
Convert map of nodes to YAML
CREATE (a:Test {foo: 7}), (b:Test {bar: 9})
RETURN apoc.convert.toYaml({one: a, two: b}) AS value, elementId(a) AS idA, elementId(b) AS idB
value |
---|
|
Convert path to YAML
CREATE p=(a:Test {foo: 7})-[r1:TEST]->(b:Baz {a:'b'})<-[r2:TEST_2 {aa:'bb'}]-(c:Bar {one:'www', two:2, three: localdatetime('2020-01-01')})
RETURN apoc.convert.toYaml(p) AS value, elementId(a) AS idTest, elementId(b) AS idBaz, elementId(c) AS idBar, elementId(r1) AS idTEST, elementId(r2) AS idTEST_2
value |
---|
|