Skip to content

Convert YAML string issue #129

@hangwang200

Description

@hangwang200

jackson-dataformat-yaml 2.8.11

read file config like this:

 gemfireSwitchForRegions:
    maxConnections: '20'
    user: 'OFF'
    legalEntity: 'ON'

----
java

ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory().enable(Feature.MINIMIZE_QUOTES));
JsonNode jsonNode = objectMapper.readTree(inputStream);
SequenceWriter sw = objectMapper.writer().writeValues(System.out);
sw.write(jsonNode);

----
output:

  gemfireSwitchForRegions:
    maxConnections: 20
    user: OFF
    legalEntity: ON


read file config like this:

 gemfireSwitchForRegions:
    maxConnections: '20'
    user: OFF
    legalEntity: ON

----
java

ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory().enable(Feature.MINIMIZE_QUOTES));
JsonNode jsonNode = objectMapper.readTree(inputStream);
SequenceWriter sw = objectMapper.writer().writeValues(System.out);
sw.write(jsonNode);

----
output:

  gemfireSwitchForRegions:
    maxConnections: 20
    user: false
    legalEntity: true


why in the first case it will convert it will output OFF/ON, but when it reads OFF/ON, it will change to false/true?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions