0

When trying to YAML::load a value produced by YAML::dump I get an error "did not find expected key while parsing a block mapping at line 1 column 1"

The YAML::dump value was written to an XML file as:

<format_store>---:text_formatting: '':url_pattern: ''</format_store>

If I look into the database, it is a text field with line breaks in it.

---
:text_formatting: ''
:url_pattern: ''

So it looks like the conversion from YAML::dump into the XML format dropped the line breaks. I explicitly use the YAML::dump format for text fields. XML does not allow line breaks in element values. It would have to be escaped in some way and I assumed YAML would take care of that.

Is there a better way to dump/load text fields or is there someting I'm missing here?

GTeley
  • 23
  • 9

1 Answers1

0

Option 1: Wrap the YAML content in a <![CDATA]]> as suggested in Adding a new line/break tag in XML.

Option 2: Configure your YAML library to dump mappings using flow style (e.g {':text_formatting' : '', ':url_pattern' : ''). The exact method for accomplishing this will depend on the YAML library you are using and may require a bit of custom coding.

bd808
  • 1,781
  • 1
  • 22
  • 31