connec / yaml-js

A port of PyYAML to CommonJS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Yaml dump including JSON object

brollb opened this issue · comments

Yaml dump of an object can include JSON syntax rather than the yaml syntax.

This can be replicated with deserialization and serialization of the following:

description: "initializes the simulation"
properties:

  • fileName:
    type: string

This will return:

description: initializes the simulation
properties:

  • fileName: {type: string}

Yes, by default sequences and mappings containing only scalars will be represented in flow style.

You can tell dump to prefer nested style by passing default_flow_style: false in the options.

yaml.dump(obj, null, null, { default_flow_style: false })

My mistake. After also checking out the behavior of pyYAML, (http://pyyaml.org/wiki/PyYAMLDocumentation), it makes sense why this is the default behavior.