yaml - SnakeYAML: How to disable underscore stripping when parsing? -


here's problem. have yaml doc contains following pair:

run_id: 2010_03_31_101

when get's parsed @ org.yaml.snakeyaml.constructor.safeconstructor.constructyamlint:159 underscores stripped , constructor returns long 20100331101 instead of unmodified string "2010_03_31_101" need.

question: how can disable behavior , force parser use string constructor instead of long?

ok. got answer form mailing list. here is

hi, according spec (http://yaml.org/type/int.html): “_” characters in number ignored, allowing readable representation of large values

you have few ways solve it. 1) not rely on implicit types, use quotes (single or double) run_id: '2010_03_31_101'

2) turn off resolver integers (as done here floats) link 1 link 2

3) define own pattern int link 3

please aware when start deviate spec other recipients may fail parse yaml document. using quotes safe.

  • andrey

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -