views:

32

answers:

1

Here's my problem. I have YAML doc that contains the following pair:

run_ID: 2010_03_31_101

When this get's parsed at org.yaml.snakeyaml.constructor.SafeConstructor.ConstructYamlInt:159 underscores get stripped and Constructor returns Long 20100331101 instead of unmodified String "2010_03_31_101" that I really need.

QUESTION: How can I disable this behavior and force parser to use String constructor instead of Long?

+1  A: 

OK. Got answer form their mailing list. Here it is

Hi, according to the spec (http://yaml.org/type/int.html): Any “_” characters in the number are ignored, allowing a readable representation of large values

You have a few ways to solve it. 1) do not rely on implicit types, use quotes (single or double) run_ID: '2010_03_31_101'

2) Turn off resolver for integers (as it is done here for floats) link 1 link 2

3) Define your own pattern for int link 3

Please be aware that when you start to deviate from the spec other recipients may fail to parse your YAML document. Using quotes is safe.

  • Andrey
DroidIn.net